Height="{Binding Source=Self, Path=Width}"
Width="627"
这行不通。一开始,Height长度为Width,但是当我改变时Width,Height不想改变。
这里有什么问题?
Height并Width定义您希望元素的大小。
在渲染视觉效果期间,元素的可用大小会根据其他所有内容进行计算,ActualHeight并且ActualWidth会更新。
HeightandWidth不会因为这个计算而改变,但是如果Height和Width被改变,ActualHeight和ActualWidth被重新计算。
改变你Binding的使用路径ActualWidth,你应该得到一个正方形。
Height="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"
您应该使用RelativeSource绑定:
Height="{Binding ActualWidth,RelativeSource={RelativeSource Mode=Self}}"