RadContextMenu with RadTreeView

3 posts, 0 answers
  1. mal
    mal avatar
    6 posts
    Member since:
    Dec 2010

    Posted 25 Feb 2011 Link to this post

    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. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3082 posts

    Posted 02 Mar 2011 Link to this post

    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!
  3. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 03 Mar 2011 Link to this post

    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!
Back to Top