I have a TreeView for which I am trying to make a ContextMenu. The ContextMenu needs to have a couple of static MenuItems: "test" and "test." It should also have a list of MenuItems within a MenuItem that presents the user with a list of dynamically loaded options (Binding to Parent.Parent.Children).
I can't figure out how to combine a DataTemplate with static MenuItems. This is my best attempt:
<TreeView x:Name="SpatialHierarchyTree" DataContext="{Binding topContainer}" ItemsSource="{Binding Project}" >
<TreeView.Resources>
<ContextMenu x:Key="moveContext" StaysOpen="True" ItemsSource="{Binding Parent.Parent.Children}">
<MenuItem Header="Test"/>
<MenuItem Header="Test"/>
<MenuItem Header="List">
<ContextMenu.ItemTemplate>
<DataTemplate>
<MenuItem Header="{Binding Name}" CommandParameter="{Binding Name}" Click="MenuItem_Click"/>
</DataTemplate>
</ContextMenu.ItemTemplate>
<MenuItem/>
</ContextMenu>
</TreeView.Resources>
</TreeView>
Is there a way to achieve this?