tags:

views:

84

answers:

2
<StackPanel Grid.Row="0" Height="Auto" Width="Auto">
         <Label Name="Label1" BorderThickness="2,2,2,2" BorderBrush="Gray"  HorizontalContentAlignment="Center" Width="Auto" Height="28">Window1</Label>               
            <ListView BorderThickness="2,0,2,0" BorderBrush="Gray" Height="Auto" Width="Auto">                                   
            </ListView>
      </StackPanel>

In the XAML above , I want to dock the ListView on the StackPanel. I want that ListView will take the entire client area of stack panel after the Label.

Please suggest me where I am doing wrong!!

Thanks in advance for simple query...

+2  A: 

Why not use a DockPanel instead

<DockPanel Grid.Row="0" Height="Auto" Width="Auto">
     <Label DockPanel.Dock="Left" Name="Label1" BorderThickness="2,2,2,2" BorderBrush="Gray"  HorizontalContentAlignment="Center" Width="Auto" Height="28">Window1</Label>               
     <ListView BorderThickness="2,0,2,0" BorderBrush="Gray" Height="Auto" Width="Auto" />
</DockPanel>
HakonB
A: 

Long story short, the StackPanel is not meant to stretch its children, it will just stack them as they come. You want a DockPanel.

This has been discussed before.

Tiberiu Ana