Reputation: 1189
Height="{Binding Source=Self, Path=Width}"
Width="627"
This doesn't work. To begin, Height
gets a length of Width
, but when I am changing Width
, Height
doesn't want to change.
What is wrong here?
Upvotes: 0
Views: 87
Reputation: 2320
Height
and Width
define the size you want your element to be.
During the rendering of your visuals, the available size for your element is calculated in relation to everything else, and the ActualHeight
and ActualWidth
are updated.
Height
and Width
do not change as a result of this calculation, but if Height
and Width
are changed, the ActualHeight
and ActualWidth
are recalculated.
Change your Binding
path to use the ActualWidth
and you should end up with a square.
Height="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"
Upvotes: 1
Reputation: 2190
You should use RelativeSource
binding:
Height="{Binding ActualWidth,RelativeSource={RelativeSource Mode=Self}}"
Upvotes: 1