Hi everybody.
I am doing a project with WPF, it's the first time, so i am not an expert in WPF, and i have some problems with treeView.
I am trying to create a treeView from an instance of my class menu. A menu is composed by Items and every Item can have a collection of subItems, which can also have subItems and so on...
I am initializing my menu and everything is right, but when i try to use the dataBinding to show the content of my menu in a treeView i have many problems, and i am searching for a solution, but didn't find anything.
Here is my xaml code:
<Grid.Resources>
<HierarchicalDataTemplate x:Key="Temp">
<TreeViewItem ItemsSource="{Binding Path=ViewModelPropertyMenu.it/Subitems, Source={StaticResource Locator}}" Header="{Binding Path=ViewModelPropertyMenu.it/Label, Source={StaticResource Locator}}" />
</HierarchicalDataTemplate>
</Grid.Resources>
....
<pre lang="xml"><TreeView AllowDrop="True" >
<TreeViewItem Header="{Binding Path=Name}" ItemTemplate="{StaticResource Temp}" ItemsSource="{Binding Path=it, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</TreeView>
I am using the patterns MVVM and Locator, so The class locator is used to locate the ViewModel Classes i am using.
The treeView generated shows three items which have the same name (the name of the first item, and my menu is really composed of three items) then for every Item, it shows 11 subItems ( only my first Item have 11 SubItems) but it shows them under this form "Project.Model.Items"
Thanks in Advance. I am really lost. It has been a week since i am searching for a solution. :sigh: