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

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

1 Answer 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Leslie
Top achievements
Rank 1
Leslie asked on 18 Feb 2011, 09:17 PM
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">
    <RadTreeView.ItemTemplate>
    <telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildTree}">
    <TextBlock Text="{Binding nodename, Mode=OneWay}" Foreground="{StaticResource TextBrush}" Margin="3,0,0,0">
        <telerik:RadContextMenu.ContextMenu>
            <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>
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>
    </TextBlock>
    </telerik:HierarchicalDataTemplate>
    </RadTreeView.ItemTemplate>
    <RadreeView.ItemEditTemplate>
    <DataTemplate>
    <ce:CmpTextBox Text="{Binding nodename, Mode=TwoWay}" IsLocked="{Binding IsRoot}" />
    </DataTemplate>
    </RadTreeView.ItemEditTemplate>
</RadTreeView>

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;
                    }
                
            }
            break;
    }
}

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 23 Feb 2011, 05:19 PM
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.

Regards,
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!
Tags
TreeView
Asked by
Leslie
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or