RelayCommand deriving from RibbonCommand

Ribbon for WPF Forum

Posted 12 years ago by Bjørnar Sundsbø - Norway
Version: 12.2.0570
Avatar

Hi

We have implemented our application using MVVM, and for our commands we have used the RelayCommand pattern to implement commands in our ViewModels as specified here: https://gist.github.com/2648922

With ribbon controls, you have the nice feature of hooking up gestures and displaying the shortcut we would like to take advantage of. Since InputGestures is part of RoutedCommand and not part of an interface, there doesn't seem to be a direct way of supporting this in our ICommand implementation. While working on trying to figure this out, perhaps you have some suggestions on getting this working?

I would like to add this to my RelayCommand class or something, so I don't have to add those bindings in XAML. Of course this is probably somewhat "agianst" the MMVM pattern, but I am willing to live with that :)Save Changes

[Modified 12 years ago]


Bjørnar Sundsbø

Comments (5)

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

Hi, as you saw, the InputGestures collection is defined on RoutedCommand and not on an interface so there is no other way to get that info from the command itself (since we special case RoutedCommands to look for that data).

The only other way to display input gesture text is by setting the InputGestureText property that is defined on each ribbon:Button, PopupButton, and SplitButton instance.


Actipro Software Support

Posted 12 years ago by Bjørnar Sundsbø - Norway
Avatar

Would you consider adding an interface with this property and implement it on RibbonCommand, and special cast to that type instead of RoutedCommand? That way this can be extended by developers not using RoutedCommands?

[Modified 12 years ago]


Bjørnar Sundsbø

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

Hi Bjørnar,

What if we added an InputGestureText property to IRibbonCommandUIProvider?  That way you could use the RibbonCommandUIManager to register a RibbonCommandUIProvider with that custom input gesture text for any ICommand.


Actipro Software Support

Posted 12 years ago by Bjørnar Sundsbø - Norway
Avatar

I thought the shortcut text was derived from what bindings are, and not necessarily from InputGestureText property. Perhaps a long time since I did this, or poor research on my part (sorry about that). I don't know just providing the text will acutally allow the bindings to work. Perhaps I need to do a bit of implementation to get the bindings working properly, even if displaying the shortcut is easily achieved.

I am currently working on something else, so i will have to follow up on this when I get back to this task again.


Bjørnar Sundsbø

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Well the key bindings are what allow hot keys to be recognized. Nothing will work without them.

Our screen tips will look at the input bindings and derive input gesture text to show. But you can also set the InputGestureText property on specific controls to override the derived text, or show something in cases that a non RoutedCommand is used, as in your case.


Actipro Software Support

The latest build of this product (v24.1.3) 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.