假设我在堆栈布局中有一个按钮,该按钮水平填充了父对象。如何使其垂直高度与水平长度相同?最好完全使用xaml,但如果需要则使用c#。
答案 0 :(得分:1)
我认为最简单的方法是将对象的高度绑定到其宽度
Height="{Binding RelativeSource={RelativeSource Self}, Path=Width}">
答案 1 :(得分:1)
您可以在代码中执行以下操作:
button.SetBinding(VisualElement.HeightRequestProperty, new Binding() { Source = button, Path = "Width" });