i have list of items this list have another list of items how to bind it to the TreeView
public List<JobesGroup> JobeGroups { get; set; } = new List<JobesGroup>()
{
new JobesGroup()
{
ID=1,
GroupName="test1",
Jobes=new List<Jobe>()
{
new Jobe()
{
ID=1,
JobeName="sss"
},
new Jobe()
{
ID=2,
JobeName="aaa"
}
}
},
new JobesGroup()
{
ID=2,
GroupName="test2",
Jobes=new List<Jobe>()
{
new Jobe()
{
ID=3,
JobeName="ddd"
},
new Jobe()
{
ID=4,
JobeName="fff"
}
}
}
};
i need the treeview main item is the GroupName and the subitemes is JobeName
What I have tried:
<TreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<HierarchicalDataTemplate DataType="{x:Type vs:JobesGroup}" ItemsSource="{Binding JobeGroups}">
<TextBlock Text="{Binding GroupName}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type vs:Jobe}">
<TextBlock Text="{Binding JobeName}" />
</DataTemplate>
</TreeView>
and
<TreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding JobeGroups}">
<HierarchicalDataTemplate DataType="{x:Type vs:JobesGroup}" ItemsSource="{Binding JobeGroups}">
<TextBlock Text="{Binding GroupName}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type vs:Jobe}">
<TextBlock Text="{Binding JobeName}" />
</DataTemplate>
</TreeView>
and
<TreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding JobeGroups}">
<HierarchicalDataTemplate >
<TextBlock Text="{Binding GroupName}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type vs:Jobe}">
<TextBlock Text="{Binding JobeName}" />
</DataTemplate>
</TreeView>