如何在C# Markup中将Frame的高度设置为与自身宽度相等
对应C#实现代码如下
// 初始化BoxView控件 var redBoxView = new BoxView { Color = Colors.Red, WidthRequest = 200, HorizontalOptions = LayoutOptions.Center }; // 实现HeightRequest绑定自身WidthRequest的逻辑 redBoxView.SetBinding( BoxView.HeightRequestProperty, new Binding( path: nameof(BoxView.WidthRequest), source: RelativeBindingSource.Self ) );
如果你需要为Frame实现同样的动态绑定逻辑,只需要将上述代码中的BoxView类型替换为Frame即可,绑定规则完全通用。
内容的提问来源于stack exchange,提问作者KNewton
相关产品推荐
相关产品推荐

