【发布时间】:2013-02-10 20:09:20
【问题描述】:
我有一个按姓名的第一个字母分组的人员列表。
结果如下:
问题是 D 组和 G 组之间的空间,我该如何删除它?
GroupStyle 是这样声明的:
<GridView.ItemTemplate>
<DataTemplate>
<Border Width="150" Height="150" Background="#FFF14B01">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" Foreground="White" />
</Grid>
</Border>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.GroupStyle>
<GroupStyle HidesIfEmpty="True">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="1,0,0,20">
<TextBlock FontWeight="Bold" Style="{StaticResource SubheaderTextStyle}" Text="{Binding Title}" />
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Margin="0,0,80,0" ItemHeight="150" ItemWidth="150" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
Key/Value 集合中没有带有空集合的键。
实际上,如果组“A”在 5 列上,即使只有一项,每个组也会有 5 列空间。
所以,在图片中,D 有 3 列空间,G 也有。
提前致谢
编辑:
添加这个问题解决了:
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
感谢您的回答
【问题讨论】:
-
你应该把
<VariableSizedWrapGrid Margin="0,0,80,0">改成<VariableSizedWrapGrid Margin="0"
标签: xaml windows-8 windows-runtime