Context Menu doesn't show input gestures?

Ribbon for WPF Forum

Posted 15 years ago by Jason
Version: 4.5.0485
Avatar
In the normal WPF ContextMenu, if I add commands to MenuItems in a context menu, the keyboard shortcut is displayed, along with the command text, for something like "Open CTRL+O". But when I hook up a command to an actipro button in menu of a context menu, I don't get this "free" behavior. Is this something I now need to hook up manually, or is this supported in a different manner?

normal:

<Window x:Class="WpfApplication1.Window3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window3" Height="300" Width="300">
<StackPanel>
<TreeView x:Name="treeView">
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Open"/>
<MenuItem Command="ApplicationCommands.New" />
<MenuItem Command="ApplicationCommands.Close"/>
</ContextMenu>

</TreeView.ContextMenu>
</TreeView>
</StackPanel>
</Window>

actipro:
<Window x:Class="WpfApplication1.Window3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:apc="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon.Controls;assembly=ActiproSoftware.Ribbon.WPF30"
Title="Window3" Height="300" Width="300">
<StackPanel>
<TreeView x:Name="treeView">
<TreeView.ContextMenu>
<apc:ContextMenu>
<apc:Menu>
<apc:Button Command="ApplicationCommands.Open" />
<apc:Button Command="ApplicationCommands.Close" />
<apc:Button Command="ApplicationCommands.New" />
</apc:Menu>
</apc:ContextMenu>

</TreeView.ContextMenu>
</TreeView>
</StackPanel>
</Window>

same code for both:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window3.xaml
/// </summary>
public partial class Window3 : Window
{
public Window3()
{
InitializeComponent();
treeView.Items.Add("1");
treeView.Items.Add("21");
treeView.Items.Add("31");
treeView.Items.Add("41");
treeView.Items.Add("51");
treeView.ContextMenu.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, Execute, CanExecute));
treeView.ContextMenu.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, Execute, CanExecute));
treeView.ContextMenu.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, Execute, CanExecute));
}

public void Execute(object sender, ExecutedRoutedEventArgs e)
{

}

public void CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}
}

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

Good news, this is an item we've had on our TODO list for a while and it's ready to go for the next maintenance release. Context menus will show the keyboard shortcut by default from now on (when ribbon:ContextMenu is used).


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.