Show context menu for tree view from keyboard shows silverlight menu also

2 posts, 0 answers
  1. Leslie
    Leslie avatar
    17 posts
    Member since:
    Jul 2010

    Posted 18 Feb 2011 Link to this post

    I am using Silverlight 4 and Q3 2010 SP1 controls for silverlight.  I am trying to get the context menu to popup using the keyboard (the right click button located just left of the right hand ctrl key on my keyboard).  The menu pops up fine, but so does the silverlight context menu.  Is there a way to prevent the silverlight context menu from showing as well?  The right mouse button works fine. 

    Here is my tree declaration:

    <RadTreeView x:Name="nodeTree" Grid.Row="1" IsDragDropEnabled="True" IsEditable="True" SelectionChanged="nodeTree_SelectionChanged" SelectionMode="Single" ItemsSource="{Binding bocNodes}" KeyDown="TreeEntryControl_KeyDown">
        <telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildTree}">
        <TextBlock Text="{Binding nodename, Mode=OneWay}" Foreground="{StaticResource TextBrush}" Margin="3,0,0,0">
                <telerik:RadContextMenu x:Name="treeContextMenu" Opened="treeContextMenu_Opened">
                    <telerik:RadMenuItem x:Name="treeMenuAbove" Header="{Binding LStrings.ElectronicTemplates_AddAbove, Source={StaticResource Strings}}" Click="treeMenuItem_ClickAbove" IsEnabled="{Binding IsRoot, Converter={StaticResource myNotConverter}}"></telerik:RadMenuItem>
                    <telerik:RadMenuItem x:Name="treeMenuChild" Header="{Binding LStrings.ElectronicTemplates_AddChild, Source={StaticResource Strings}}" Click="treeMenuItem_ClickChild"></telerik:RadMenuItem>
                    <telerik:RadMenuItem x:Name="treeMenuBelow" Header="{Binding LStrings.ElectronicTemplates_AddBelow, Source={StaticResource Strings}}" Click="treeMenuItem_ClickBelow" IsEnabled="{Binding IsRoot, Converter={StaticResource myNotConverter}}"></telerik:RadMenuItem>
                    <telerik:RadMenuItem x:Name="treeRename" Header="{Binding LStrings.ElectronicTemplates_Rename, Source={StaticResource Strings}}" Click="treeMenuItem_Rename" IsEnabled="{Binding IsRoot, Converter={StaticResource myNotConverter}}"></telerik:RadMenuItem>
                    <telerik:RadMenuItem x:Name="treeMap" Header="{Binding LStrings.ElectronicTemplates_Map, Source={StaticResource Strings}}" Click="treeMenuItem_Map" IsEnabled="{Binding IsRoot, Converter={StaticResource myNotConverter}}"></telerik:RadMenuItem>
        <ce:CmpTextBox Text="{Binding nodename, Mode=TwoWay}" IsLocked="{Binding IsRoot}" />

    And here is my code for capturing the keydown event:
    public static void TreeEntryControl_KeyDown(CmpTreeView MainControl, object sender, KeyEventArgs e)
        RadTreeViewItem selected;
        switch (e.Key)
            case Key.Unknown:
                if (e.PlatformKeyCode == 93)
                    var box = MainControl.SelectedContainer.ChildrenOfType<TextBlock>();
                    if (box != null && box.Count > 0)
                        var menu = RadContextMenu.GetContextMenu(box[0]);
                        if (menu != null)
                            menu.IsOpen = true;
                            e.Handled = true;

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 23 Feb 2011 Link to this post

    Hi Leslie,

    I couldn't reproduce the issue on our side. Can you please have a look at this video and the attached sample and let me know if it works for you or if I am missing something. Thank you in advance.

    Tina Stancheva
    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