I’m working right now with the TreeView. As you can see CurrentMediumObjectives and ChildrenObjective are the same object type called Objective.
This class has a property called Level, where in ChildrenObjective is set to 1 and ChildrenObjective is set to 2.
I would like to set a different DataTemplate depending on the Level.
<TreeView ItemsSource="{Binding CurrentMediumObjectives}"
Margin="0,40,0,0">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildrenObjective}">
<TextBlock FontWeight="Bold">
<Run Text="Objective " />
<Run Text="{Binding Level}" />
</TextBlock>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
I’m confusing about if should I use a DataTemplateSelector or a DataTrigger.
Thanks in advance.
Perhaps you could just use a
Triggerto show each template.Somthing like this, maybe:
Model (Guess)
Result:
