Ok, so I am not sure this is even possible but I will ask the question here and hope to get an answer to it.
Suppose I have a list of a class, say Media items defined as follows
Enum MediaItemType{
Book,
CD,
VideoGame
}
public MediaItem{
public string Name { get; set; }
public MediaItemType { get; set; }
}
Now suppose I want to bind a list of MediaItems to a TreeView such that each MediaItem ends upp in a separate subtree depending on the media item type. Is that possible to do and if so, how do I do that?
In my Xaml-code I assume that I have defined the list as a property named MediaItems in the context.
<Grid>
<TreeView ItemsSource="{Binding Path=MediaItems}">
</Grid>
The tree view should be something like this
Book
- In to the wild
- Code Complete
CD
- Foo Fighters
- Bach
DVD
- X-men
- Casino Royale
I don’t know about about a tree view, but you could achieve something similar to what you describe using a GroupDescription grouping on the MediaItemType property with a ListBox or ListView as described here