我已经和这个问题斗争了很长一段时间,我需要一些专家的帮助才能得到我想要的结果。下面是我的带有gridviewcolumn的列表视图的结果,它将源绑定为lstPerson,并将其DataMember绑定到性别和名称。
Person类:
private int ID { get; set; }
private string Gender { get; set; }
private string FName { get; set; }
List<Person> lstPerson = GetPersonInformation();
//select Gender, FirstName From Person Order By GenderListView结果:
John
Mike
Gabriel
Kevin
Peter
Stacy
Jen
Lily
Lisa
Vivian上面不是我想要显示的内容。如果我想要上述功能,那就很容易做到了。下面的结果是我想要实现的结果。对于此示例,最大值为4列,最大值为3行...每3行创建一列3行,直到达到4列。
Male Gabriel Female Lily
John Kevin Stacy Lisa
Mike Peter Jen Vivian有人知道我如何通过XAML或代码隐藏来实现这一点吗?
发布于 2012-12-07 15:23:03
您可以尝试使用ItemsPanelTemplate
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="200" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5 0" Text="{Binding FName}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>如果只需要4列,即使名称很长,也可以使用UniformGrid而不是WrapPanel
<ItemsPanelTemplate>
<UniformGrid Columns="4" />
</ItemsPanelTemplate>发布于 2012-12-07 21:53:09
你的需求排序列表--仅此而已!
<ListBox x:Name="lbPeoples" ScrollViewer.VerticalalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=Peoples}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>其中: ListBox Height = 3*Item_Height,ListBox Width = 4*Item_Width
People=男性,Peoples6 =女性电子邮件
不是很好的方法--但是很简单!
https://stackoverflow.com/questions/13754971
复制相似问题