InputGestureText not updated on changes

Ribbon for WPF Forum

Posted 7 years ago by Kasper
Version: 12.1.0562
Avatar

Hi guys,

It seems that if I change the InputGesture on a Command, the change is not reflected in e.g. Ribbon buttons. It's really easy to reproduce, you simply need a Ribbon button with a Command and then change the InputGestures of the Command during runtime, like this:

ApplicationCommands.New.InputGestures.Clear();
ApplicationCommands.New.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift));

 The application will respond to the new gesture, but the Ribbon button will still show the old one. I'm testing it like this:

<ribbon:PopupButton Label="Testing" Command="New">			
	<ribbon:Menu>
		<ribbon:Button Command="New" Label="Test" ribbon:Menu.IsMenuItemInputGestureTextVisible="True" />
	</ribbon:Menu>
</ribbon:PopupButton>

 The input gesture will remain the same in both the button tooltip and the menu text.

As a side question: Why does ribbon:Menu.IsMenuItemInputGestureTextVisible default to false? I really find this odd, because why wouldn't you want to show keyboard shortcuts in most cases? Shouldn't it default to true, so I don't have to remember to turn it on for all my menu buttons? :)

Comments (3)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

The Button.InputGestureText is a dependency property you can set.  Our menu item template binds to that property.  If you haven't set it and there is a command attached, it will try to coerce text based on the input gestures that are assigned.  It doesn't update though because nothing is really watchable on the command's input gestures to know that something changed.  So you may need to manually set the button's InputGestureText in that case.

IsMenuItemInputGestureTextVisible is probably false since I believe most menu items in Office don't show the shortcuts.  Only context menus do.


Actipro Software Support

Posted 7 years ago by Kasper
Avatar

Hi,

>The Button.InputGestureText is a dependency property you can set. Our menu item template binds to that property. If you haven't set it and there is a command attached, it will try to coerce text based on the input gestures that are assigned. It doesn't update though because nothing is really watchable on the command's input gestures to know that something changed. So you may need to manually set the button's InputGestureText in that case.

The problem is that I allow my users to customize the shortcuts at runtime (as I believe a lot of other applications do), so setting the InputGestureText in design time doesn't really help. I would love to iterate through ALL the Ribbon buttons in the window and update their InputGestureText property if the user changes their shortcuts, but I'm not really sure how that would be done? I have buttons on several tabs and even outside the Ribbon (on ToolWindows). But perhaps there's a better way - could you point me in the right direction here?

>IsMenuItemInputGestureTextVisible is probably false since I believe most menu items in Office don't show the shortcuts. Only context menus do.

I see! I guess it makes sense then :)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Sorry but that may be the only way to do it since again, WPF doesn't have any sort of notifications for when input gestures are altered on a command.  You'd probably have to recursively run through the entire control hierarchy of your windows to kick off the updates.  Definitely not fun, but I'm not sure of another way.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.