I am using WPF4 v11.2.
If I have a range highlighted and I press Ctrl S, the range gets deselected. The grid does not appear to do this when other Ctrl key combinations are pressed.
Can you tell me why this is and how to prevent it?
Hello,
Thank you for your post. I have been looking into it and I can say that this is the designed behavior of the XamDataGrid. In order to disable this, you can handle CommandExecuting event and check if the Command’s Name is “ClearAllSelected” and if so you can set the e.Handle to true to cancel executing. I attached a sample project with this approach. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Thanks Stefan. Although your sample does indeed solve the issue. I noticed I was also executing ClearAllSelected in response to other events. I was concerned about blocking that command so instead I overrode OnKeyDown and do not call the base if Control and S are the key args.
Just another note: In my app (and somewhat an industry standard) is that I use the Control S accelerator of File Save in an MDI/XamDockManager app. Not sure if it was the best design choice to have xamDataGrid contending with Control S or other ApplicationCommands key gestures (this would not apply to Copy/Paste, etc).
As always, thanks for your expert help.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Just for the record: The keyboard shortcut you chose here is inappropriate. According to the Windows UX Guidelines, Ctrl+S *must* have no other meaning than "save". Assigning it to a rather obscure feature is simply the wrong thing to do.
I just stumbled upon this post, and I completely agree. We should not be using CTRL+S for anything since it is most often used for "Save". I will look into making a breaking change and removing this shortcut mapping. Is there a different combination you would recommend?
Great, thanks. Actually, I would recommend not assigning any shortcut here. I've never come across an application that has a "clear selection" shortcut and wouldn't try finding one either. Whatever shortcut you may think of may already be used differently in a developer's application, so you would even increase the risk of breaking something by assigning a new shortcut.
Agreed! We are removing this now, so this mapping will not exist in 15.2.