2009-11-23 5 views
0
<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> 

Dans le code XAML ci-dessus, je souhaite ancrer le ListView sur le StackPanel. Je veux que le ListView prenne la totalité de la zone client du StackPanel après le Label.Comment ancrer ListView sur un StackPanel?

Qu'est-ce que je fais mal?

Répondre

2

Pourquoi ne pas utiliser un DockPanel à la place

<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> 
0

Longue histoire courte, la StackPanel ne vise pas à étirer ses enfants, il suffit de les empiler comme ils viennent. Vous voulez un DockPanel. Ceci a été discussed before

Questions connexes