WPF - Adopt size of parent
The Width
and Height
properties are primarily designed for setting requested dimensions.
If you are using dynamic layouts with stretching, etc. bind to the ActualWidth
and ActualHeight
properties:
<Binding RelativeSource="{RelativeSource ...}" Path="ActualWidth"/>
I was trying to do something similar, found this to work well:
Width="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListBox}},Path=ActualWidth}"
Check out: social.msdn.microsoft