自定义视图 listview 绑定 WPF
嗨,我有下一个 XAML 标记(当然只是一部分):
<Window.Resources>
<GridView x:Key="gridview">
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Title}">
<GridViewColumnHeader Content="Titel" Tag="Title" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Artist}">
<GridViewColumnHeader Content="Artiest" Tag="Artist" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Album}">
<GridViewColumnHeader Content="Album" Tag="Album" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="50" DisplayMemberBinding="{Binding Genre}">
<GridViewColumnHeader Content="Genre" Tag="Genre" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="50" DisplayMemberBinding="{Binding Jaar}">
<GridViewColumnHeader Content="Jaar" Tag="Jaar" Click="SortClick"/>
</GridViewColumn>
</GridView>
<my:IdToImageConverter x:Key="idToImageConverter" />
<DataTemplate x:Key="iconTemplate">
...
</DataTemplate>
<my:PlainView x:Key="iconView"
ItemTemplate="{StaticResource iconTemplate}"
ItemWidth="300"/>
</Window.Resources>
<Grid>
<ListView Name="LibView" ItemsSource="{Binding ElementName=win, Path=Biblio}"/>
</Grid>
Biblio 是包含 LibView 元素的可观察集合 iconView 和 gridview 是我用于 LibView 的视图。这非常有效。
现在我想添加一个视图,将每个元素按“艺术家”分组,并且我想显示如下:
Artist1 - TitleA - AlbumA - TitleB - AlbumB - TitleC - AlbumC Artist2 - TitleD - AlbumD ...
我想我必须制作某种模板,但我什至不知道使用 XAML 是否可以做到这一点。
Hi I have next XAML markup (just a piece of course):
<Window.Resources>
<GridView x:Key="gridview">
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Title}">
<GridViewColumnHeader Content="Titel" Tag="Title" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Artist}">
<GridViewColumnHeader Content="Artiest" Tag="Artist" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="200" DisplayMemberBinding="{Binding Album}">
<GridViewColumnHeader Content="Album" Tag="Album" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="50" DisplayMemberBinding="{Binding Genre}">
<GridViewColumnHeader Content="Genre" Tag="Genre" Click="SortClick"/>
</GridViewColumn>
<GridViewColumn Width="50" DisplayMemberBinding="{Binding Jaar}">
<GridViewColumnHeader Content="Jaar" Tag="Jaar" Click="SortClick"/>
</GridViewColumn>
</GridView>
<my:IdToImageConverter x:Key="idToImageConverter" />
<DataTemplate x:Key="iconTemplate">
...
</DataTemplate>
<my:PlainView x:Key="iconView"
ItemTemplate="{StaticResource iconTemplate}"
ItemWidth="300"/>
</Window.Resources>
<Grid>
<ListView Name="LibView" ItemsSource="{Binding ElementName=win, Path=Biblio}"/>
</Grid>
Biblio is the observable collection containing the elements for LibView
iconView and gridview are the views i use for LibView. This works perfectly.
Now i want to add a view wich groups every element by "Artist", and i want to display this like:
Artist1 - TitleA - AlbumA - TitleB - AlbumB - TitleC - AlbumC Artist2 - TitleD - AlbumD ...
I guess i have to make some kind of template but i don't even know if this is possible using XAML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你想要一个 GroupStyle - 这可能会解释:
http://bea.stollnitz.com/blog/?p=17
有很多例子 - 尝试在 wpf groupstyle 上搜索:)
It sound like you want a GroupStyle - this might explain:
http://bea.stollnitz.com/blog/?p=17
There are many examples - try a search on wpf groupstyle :)