1
<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" />                                   
</StackPanel>

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

What am I doing wrong ?

perror
  • 7,071
  • 16
  • 58
  • 85
Ashish Ashu
  • 14,169
  • 37
  • 86
  • 117
  • 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](https://stackoverflow.com/questions/569095/wpf-xaml-how-to-get-stackpanels-children-to-fill-maximum-space-downward). – Tiberiu Ana Nov 23 '09 at 09:51

1 Answers1

3

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
  • 6,977
  • 1
  • 26
  • 27