将包含项的组添加到WPF ListView [英] Adding groups with items to WPF ListView
本文介绍了将包含项的组添加到WPF ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是的,我已经花了好几个小时才做到这一点并没有太大的成功。我想要做的是当用户点击一个按钮时,它应该加载一个包含几个组的列表视图(扩展器在(样式在下面))然后添加一些项目到组,其中有一个项目和一个子项目。以下代码是listview项目样式的XAML:
Right, I have been trying for hours to do this with not much success. What I want to do is when the user clicks a button it should load a listview with a few groups (with expanders in(style is below)) then add a few items to the groups with there being an item and a subitem with it. The following code is the XAML for the style of the listview items:
<ListView Height="Auto" HorizontalAlignment="Left" Margin="1149,0,0,0" Name="dataTree" VerticalAlignment="Stretch" Width="292">
<ListView.GroupStyle>
<GroupStyle HidesIfEmpty="False">
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<Expander IsExpanded="True">
<Expander.Header>
<Bold>
<TextBlock Text="{Binding Name}"/>
</Bold>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="Parameter" Width="150" DisplayMemberBinding="{Binding Param}"/>
<GridViewColumn Header="Value" Width="100" DisplayMemberBinding="{Binding (originally 'group.Param' but not sure how this part works)}" />
</GridView>
</ListView.View>
</ListView>
基本上我只是想知道如何将组和项添加到WPF中的listview。比窗户形式要难得多。谢谢。
Basically I just want to know how to add groups and items to them to a listview in WPF. Much harder than windows forms. Thank you.
推荐答案
也许这就像这里可以帮助你:
http://www.wpf-tutorial.com/listview-control/listview-grouping/ [ ^ ]
和来自MSDN的文档总是值得一看:
http:/ /msdn.microsoft.com/en-us/library/windows/apps/hh780627.aspx [ ^ ]
希望这会有所帮助:)
Perhaps this like here could help you:
http://www.wpf-tutorial.com/listview-control/listview-grouping/[^]
And the documentation from MSDN is always worth a look:
http://msdn.microsoft.com/en-us/library/windows/apps/hh780627.aspx[^]
Hope this helps :)
这篇关于将包含项的组添加到WPF ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文