This is a migrated thread and some comments may be shown as answers.

Escape key and RoutedCommand

7 Answers 253 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramin
Top achievements
Rank 1
Ramin asked on 15 Oct 2010, 01:19 AM
I have setup in my code a RoutedCommand for escape key:

  public static RoutedCommand CloseFormCommand = new RoutedCommand();
  CloseFormCommand.InputGestures.Add(new KeyGesture(Key.Escape));

This works fine when the keyboard focus is on a control like a textbox in the form. But as soon as I click on the Grid and it is set to Edit mode pressing the Escape key will just finish the edit mode and it won't call the command unless I set the cursor back to the textbox by mouse and press the Escape key. How can I fix this problem?

7 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 19 Oct 2010, 09:19 AM
Hello Ramin,

You can override keyboard behavior like demonstrated in this blog post.
Let me know if this doesn't help.

Sincerely yours,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ramin
Top achievements
Rank 1
answered on 19 Oct 2010, 04:54 PM
Hi Nedyalko,
Thanks for the response. I've looked at the blog you sent. I don't have any problem with the function of Escape key in the Grid. Escape is canceling the edit and I need it. My problem is that after pressing escape and canceling from edit mode I need to press escape again and this time the escape should activate my RoutedCommand and this is not happening unless I change the focus from Grid to another control.
Thanks for looking into this,
0
Nedyalko Nikolov
Telerik team
answered on 22 Oct 2010, 01:52 PM
Hello Ramin,

Could you please try to register your custom command with RadGridView and let me know about the result? Code should look like:

Telerik.Windows.Controls.CommandManager.RegisterClassCommandBinding(typeof(RadGridView), new CommandBinding(yourCommand, OnExecuted, OnCanExecute));

Best wishes,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ramin
Top achievements
Rank 1
answered on 22 Oct 2010, 06:00 PM
I use WPF RadControls.
I tried this:
Telerik.Windows.Controls.CommandManager.RegisterClassCommandBinding(typeof(RadGridView), new CommandBinding(yourCommand, OnExecuted, OnCanExecute));

And I got this error:
The type or namespace name 'CommandManager' does not exist in the namespace 'Telerik.Windows.Controls' (are you missing an assembly reference?) C:\DevLcl\GiftWPF\GiftWPF\Forms\XpubPanel.xaml.cs 71 38 GiftWPF

0
Nedyalko Nikolov
Telerik team
answered on 27 Oct 2010, 10:02 PM
Hello Ramin,

Could you please send me an isolated project which I can debug on my side, and I'll do my best to resolve the problem?
Thank you in advance.

P.S. You should open a separate support ticket in order to be able to attach files.

Regards,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lynne
Top achievements
Rank 1
answered on 26 Oct 2011, 07:47 PM
Would you please update the currently-invalid blog entry link in your message?
0
Maya
Telerik team
answered on 27 Oct 2011, 06:55 AM
Hello Lynne,

The updated link to the blog post is this one. You can also run through our online documentation for further reference.
 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Ramin
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Ramin
Top achievements
Rank 1
Lynne
Top achievements
Rank 1
Maya
Telerik team
Share this question
or