开发者

Custom view listview Binding WPF

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>
        <GridVie开发者_如何学编程wColumn 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.


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜