You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 16:45:02