Hi,
I am trying to use HierarchicalDataTemplate to populate the tree items from an ObservableCollection and everything is working fine, but the context menu that I added to the tree is not getting opened. I want to add a context menu to the tree in this scenario. Any help is appreciated.
Thanks
code:
<UserControl.Resources>
<telerik:HierarchicalDataTemplate x:Key="itemTemplate" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"
Margin="0,0,5,0"
/>
</StackPanel>
</telerik:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<telerikNavigation:RadTreeView x:Name="treeView"
ItemTemplate="{StaticResource itemTemplate}">
<telerikNavigation:RadContextMenu.ContextMenu>
<telerikNavigation:RadContextMenu x:Name="contextMenu" Opened="contextMenu_Opened"
ItemClick="contextMenu_ItemClick">
<telerikNavigation:RadMenuItem Header="Add New Folder" x:Name="additem" />
<telerikNavigation:RadMenuItem Header="Add New Item" x:Name="addfold" />
<telerikNavigation:RadMenuItem Header="Edit " x:Name="edit" />
<telerikNavigation:RadMenuItem Header="Remove" x:Name="remove" />
</telerikNavigation:RadContextMenu>
</telerikNavigation:RadContextMenu.ContextMenu>
</telerikNavigation:RadTreeView>
</Grid>
I am trying to use HierarchicalDataTemplate to populate the tree items from an ObservableCollection and everything is working fine, but the context menu that I added to the tree is not getting opened. I want to add a context menu to the tree in this scenario. Any help is appreciated.
Thanks
code:
<UserControl.Resources>
<telerik:HierarchicalDataTemplate x:Key="itemTemplate" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"
Margin="0,0,5,0"
/>
</StackPanel>
</telerik:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<telerikNavigation:RadTreeView x:Name="treeView"
ItemTemplate="{StaticResource itemTemplate}">
<telerikNavigation:RadContextMenu.ContextMenu>
<telerikNavigation:RadContextMenu x:Name="contextMenu" Opened="contextMenu_Opened"
ItemClick="contextMenu_ItemClick">
<telerikNavigation:RadMenuItem Header="Add New Folder" x:Name="additem" />
<telerikNavigation:RadMenuItem Header="Add New Item" x:Name="addfold" />
<telerikNavigation:RadMenuItem Header="Edit " x:Name="edit" />
<telerikNavigation:RadMenuItem Header="Remove" x:Name="remove" />
</telerikNavigation:RadContextMenu>
</telerikNavigation:RadContextMenu.ContextMenu>
</telerikNavigation:RadTreeView>
</Grid>