Treeview vs nested Expanders
Edit 2 :
This is what i want to do with only 1 treeview :
my treeview with outlook style http://img204.imageshack.us/img204/8218/sansreju.jpg
Edit :
I want to know how make a treeview with different expander styles in terms of the level. I currently use nested expanders.
Original question :
I am trying to get a WPF Treeview that has differents expanders styles in terms of the level.
What i actually have is that :
a listview wich contains differents templates in term of the ojbect type by using a selector
<ListView Name="MyTreeView" ItemTemplateSelector="{StaticResource Selector}">
<!-- Items Template -->
<HierarchicalDataTemplate x:Key="ItemsTemplate" ItemsSource="{Binding Childrens}">
<TextBlock Text="{Binding Name}" Margin="5,0" VerticalAlignment="Center"/>
</HierarchicalDataTemplate>
<!-- SubNode Template -->
<DataTemplate x:Key="SubNodeTemplate">
<Expander Style="{StaticResource SubExpander}">
<TreeView ItemsSource="{Binding Childrens}"
ItemTemplateSelector="{StaticResource Selector}"/>
</Expander>
</DataTemplate>
<!-- Node Template -->
&开发者_JS百科lt;DataTemplate x:Key="NodeTemplate">
<Expander Style="{StaticResource MainViewExpander}">
<ListView ItemsSource="{Binding Childrens}"
ItemTemplateSelector="{StaticResource Selector}"/>
</Expander>
</DataTemplate>
And this is the code behind with object used for mapping : I got a list (of IUpSlideItem ) and apply it to MyTreeview.ItemsSource
Public Interface IUpSlideItem
Property Childrens As List(Of IUpSlideItem)
Property Name As String
End Interface
Public Class Item
Implements IUpSlideItem
Public Property Childrens As System.Collections.Generic.List(Of IUpSlideItem) Implements IUpSlideItem.Childrens
Public Property Name As String Implements IUpSlideItem.Name
End Class
Public Class Node
Implements IUpSlideItem
Public Property Childrens As System.Collections.Generic.List(Of IUpSlideItem) Implements IUpSlideItem.Childrens
Public Property Name As String Implements IUpSlideItem.Name
End Class
Now the question is to know if only 1 treeview with different expander style in terms of the type's item is possible. I need this because i want single item select only.
by using an item container style selctor you can have 1 treeview with different expander style : http://msdn.microsoft.com/fr-fr/library/system.windows.hierarchicaldatatemplate.itemcontainerstyleselector%28v=vs.90%29.aspx
edit : this solution is working, i have a perfect TreeView now
精彩评论