According to the documentation here, to get the RadTreeViewItem so that you can dynamically set the context menu, you need to add a handler for the Opened event and retrieve it like so:
We have an application using RadDocking with the RadTreeView in a RadPane. It works with the pane pinned but if I unpin the pane and right click, GetClickedElement returns null. Here's some simple XAML to recreate it:
So if I slide out the pane and right click the tree node, I get a null result whereas I get the RadTreeViewItem when the pane is pinned. I'm I using the control incorrectly?
RadTreeViewItem item = ((RadContextMenu)sender).GetClickedElement<RadTreeViewItem>();
We have an application using RadDocking with the RadTreeView in a RadPane. It works with the pane pinned but if I unpin the pane and right click, GetClickedElement returns null. Here's some simple XAML to recreate it:
<
Window
x:Class
=
"DockingTreeViewContextMenu.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
telerik:RadDocking
>
<
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
>
<
telerik:RadPaneGroup
>
<
telerik:RadDocumentPane
Header
=
"Content"
></
telerik:RadDocumentPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
>
<
telerik:RadPaneGroup
>
<
telerik:RadPane
Header
=
"Pane 1"
>
<
telerik:RadTreeView
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
Opened
=
"RadContextMenu_Opened"
>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadTreeViewItem
Header
=
"Item #1"
>
<
telerik:RadTreeViewItem
Header
=
"Item #1.1"
></
telerik:RadTreeViewItem
>
<
telerik:RadTreeViewItem
Header
=
"Item #1.1"
></
telerik:RadTreeViewItem
>
<
telerik:RadTreeViewItem
Header
=
"Item #1.1"
></
telerik:RadTreeViewItem
>
</
telerik:RadTreeViewItem
>
<
telerik:RadTreeViewItem
Header
=
"Item #2"
/>
<
telerik:RadTreeViewItem
Header
=
"Item #3"
/>
</
telerik:RadTreeView
>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking
>
</
Grid
>
</
Window
>
So if I slide out the pane and right click the tree node, I get a null result whereas I get the RadTreeViewItem when the pane is pinned. I'm I using the control incorrectly?