2009-11-23 53 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> 

在上面的XAML中,我想將ListView停靠在StackPanel上。我希望ListViewLabel之後採取StackPanel的整個客戶區域。如何將ListView停靠在StackPanel上?

我在做什麼錯?

回答

2

爲什麼不使用DockPanel中,而不是

<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

長話短說,在StackPanel並不意味着舒展它的孩子,它只是堆疊起來,因爲他們來。你想要一個DockPanel

這是discussed before

相關問題