I was able to implement the TreeView successfully and bind the complex data as ItemSource. I need to show the two different context menu. One for Parent node and another one for child nodes. I tried below code, but it shows same context menu for all nodes.
<TreeViewAdv Name="treeView" ShowRootLines="False" ItemsSource="{Binding TreeItems}">
<StackPanel Orientation="Horizontal">
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="Add"/>
<MenuItem Header="Run All"/>
<MenuItem Header="Stop"/>
<MenuItem Header="Collapse All"/>
<MenuItem Header="Expand All" />
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
//This contextmenu only shows for all nodes
<TreeViewAdv.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
<StackPanel Orientation="Horizontal">
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="Record"/>
<MenuItem Header="Run"/>
<MenuItem Header="Delete" />
</ContextMenu>
</StackPanel.ContextMenu>
<Rectangle Margin="0" Width="12" Height="12"/>
<TextBlock Margin="5 0" Text="{Binding Name}" VerticalAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeViewAdv.ItemTemplate>
</TreeViewAdv>
Please let me know, how to show the different context menu for parent and child nodes alone?
Thanks