Height="{Binding Source=Self, Path=Width}"
Width="627"
这不起作用。首先,Height
的长度为Width
,但当我更改Width
时,Height
不想更改。
这里有什么问题?
答案 0 :(得分:1)
Height
和Width
定义您希望元素的大小。
在渲染视觉效果的过程中,元素的可用尺寸会根据其他所有内容进行计算,ActualHeight
和ActualWidth
会更新。
Height
和Width
不会因此计算而发生变化,但如果更改Height
和Width
,ActualHeight
和{{1}重新计算。
更改您的ActualWidth
路径以使用Binding
,您应该最终得到一个正方形。
ActualWidth
答案 1 :(得分:1)
您应该使用RelativeSource
绑定:
Height="{Binding ActualWidth,RelativeSource={RelativeSource Mode=Self}}"