Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Showing Shortcuts in XamMenuItem Text

Hi, I've found that I can add Keyboard Shortcuts to execute commands using inputbindings inside the control

 <KeyBinding Key="F5" Command="{x:Static lcmd:SolutionProjectCommands.RefreshTree}" />

Using the code above the F5 shortcut correctly calls the command. My XamDataTree has also a context menu, so I wondered if there is a way to let the context menu elements the shorcut associated with their command to display its value to the user, when the menu is shown:

Reload (F5)

Can be the text of my command for example.

No Data
  • 34350
    Offline posted

    Hello Sabrina,

    Thank you for your post.

    I have been investigating into this and I believe your best bet here would be to write a HeaderTemplate for the XamMenuItem that you have the KeyBinding on. Using a converter, you can bind a TextBlock's text property in the HeaderTemplate to the InputBindings[0] KeyBinding that you are placing on it. Then, you can obtain the Key from it, call ToString() on that key, and return that in the converter to show the key needed for the shortcut.

    I have attached a sample application to demonstrate the above.

    Please let me know if you have any other questions or concerns on this matter.

    Associate Developer
    Infragistics Inc.