这些都是ListViews
。它们都包含最多5项。我希望它们垂直填充,所以在这种情况下,这三个项目应覆盖ListView
的3/5我该怎么做?当然,当Window
调整大小时,项目必须更改为。
http://s14.directupload.net/images/140423/c5mayx9t.png
<Grid.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border BorderBrush="#5076A7" BorderThickness="1" CornerRadius="4">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFFFF" Offset="0.0"/>
<GradientStop Color="#C0D3EA" Offset="1.0"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel TextElement.FontFamily="Segoe UI" TextElement.FontSize="12">
<TextBlock FontWeight="Bold" Padding="3,0,0,0" Text="{Binding Path=Name}"/>
<TextBlock Padding="3,0,0,0" Text="{Binding Path=Age}"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Grid.Resources>
答案 0 :(得分:0)
您可以使用UniformGrid
:
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="5" Columns="1" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>