Can someone help me understand the WPF stretch alignment. I often run into issues where I want a control to fill an area but I never understand on what level I should put the VerticalAlignment="Stretch". Specially when UserControls are involved.
I always solve the problem by trying different things or putting stretch on all levels but I would like to understand how to do it properly.
Lets take the example I got now:
- I have a grid with a fixed size cell (which can be resized with a GridSplitter)
- In this cell I have a UserControl containing a StackPanel with a TabControl
- In the TabControl I have TabItems containing another UserControl with a ListView
Or in some kind of pseudo XAML
<ns:MyUserControl1 Grid.Row="0" Grid.Column="0">
<!-- this is in MyUserControl1 -->
<StackPanel>
<TabControl>
<TabItem>
<ns:MyUserControl2>
<!-- This is in MyUserControl2 -->
<ListView/>
</ns:MyUserControl2>
</TabItem>
</TabControl>
</StackPanel>
</ns:MyUserControl>
Now I want the ListView to fill the entire grid cell (excluding the TabControl and margins of course).