Trying to add a context menu to a TreeView with just xaml code.
- Tv Show
- Season 1
- Season n
The context menu should only show when I right click a Season node.
Is that possible? I know how to solve it with code behind, but I'd like to learn to use WPF as it is intended. I have trouble finding out if I should be able to solve this with using only xaml.
Current xaml:
<TreeView Grid.Row="1" Grid.Column="0" ItemsSource="{Binding TvShows}" x:Name="TvShowsTreeView" SelectedItemChanged="TvShowsTreeViewOnSelectedItemChanged"> <TreeView.ItemTemplate> <HierarchicalDataTemplate DataType="tvShows:TvShow" ItemsSource="{Binding Seasons}"> <TextBlock Text="{Binding Name}" /> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>
HierarchicalDataTemplate? post your current XAML.