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
960
Showing Shortcuts in XamMenuItem Text
posted

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

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

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.

Parents
  • 33530
    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.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamDataTreeContextMenuShortcutCmdCase.zip
Reply Children
No Data