This is a migrated thread and some comments may be shown as answers.

[Solved] RadContextMenu with RadTreeView

2 Answers 190 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mal
Top achievements
Rank 1
mal asked on 25 Feb 2011, 10:09 PM
I have a RadContextMenu with the RadTreeView. I am populating the RadContextMenu itemsource dynamically.  I am stuck getting the selectedItem from the treeview. When I do it in code behind its straight forward, I can just say..

 

 

RadTreeViewItem selectedItem = radContextMenu.GetClickedElement<RadTreeViewItem

>();

But in my case I am using MVVM, so I prevented from using codebehind.
Here is my code snippet. The "SelectedItem" always returns null

 

 

 

 

 

 

 

 

<TelerikNavigation:RadTreeView x:Name="CaseExpoTreeView" IsRootLinesEnabled="False" IsLineEnabled="False" TelerikAnimation:AnimationManager.IsAnimationEnabled="False" IsVirtualizing="True" Grid.Row="0" ItemsSource="{Binding Case, Mode=TwoWay}" TelerikTreeView:TreeViewPanel.VirtualizationMode="Standard" ItemContainerStyle="{StaticResource DefaultTreeViewItemStyle

}">

 

<TelerikNavigation:RadContextMenu.ContextMenu  

<TelerikNavigation:RadContextMenu x:Name="radContextMenu" ItemsSource="{Binding ContextMenuItems, Mode

=TwoWay}">  

<i:Interaction.Triggers > 

<i:EventTrigger EventName ="Opened"> 
<cmd:EventToCommandTriggerAction Command="{Binding ContextMenu_OpenedCommand, Mode =OneWay}"  

CommandParameter="{Binding SelectedItem, ElementName =CaseExpoTreeView}" />  

</i:EventTrigger </i:Interaction.Triggers >

<TelerikNavigation:RadContextMenu.ItemTemplate

<Telerik:HierarchicalDataTemplate  

 

 

 

</Telerik:HierarchicalDataTemplate  

</TelerikNavigation:RadContextMenu.ItemTemplate >

 

 </TelerikNavigation:RadContextMenu>  

</TelerikNavigation:RadContextMenu.ContextMenu> 

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 02 Mar 2011, 06:21 PM
Hello mal,

We cannot see something strange in this XAML code. However, it is insufficient and any runnable sample will be highly appreciated in order to advice you better. Thank you in advance for your cooperation.

Kind regards,
Petar Mladenov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Kiril Stanoev
Telerik team
answered on 03 Mar 2011, 08:53 AM
Hello mal,

I've prepared a small project in which I try to replicate your scenario. Have a look at it and let me know if I am missing something.

Regards,
Kiril Stanoev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
mal
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Kiril Stanoev
Telerik team
Share this question
or