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

Ignoring CTRL+(key) press in RadGridView

3 Answers 394 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 2
Thomas asked on 21 Feb 2012, 10:36 AM
Hi.
I have a main window with several RadGridViews and InputBindings set up on the main Window to fire Commands of my ViewModel class. Works fine, as long as the focus is not within a RadGridView. When focus is within a RadGridView, the commands are not triggered. If I repeat the keybindings for each RadGridView e.g add:

<telerik:RadGridView.InputBindings>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{Binding MyCommand}" />
</telerik:RadGridView.InputBindings>

to each of my gridview XAML blocks, then the commands will be triggered correctly. But I would like to avoid having to repeat the bindings (there will be many).

How can I avoid the RadGridView capturing these keystrokes?

(I've tried this post, but that doesn't work with key modifiers, since it fires as soon as CTRL is pressed).

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 24 Feb 2012, 11:09 AM
Hi Thomas,

You can try exploring the approach from the blog post you mentioned and create your own custom keyboard command provider that will override the default commands and invoke those that you need. The difference will be that instead of checking just for a key, you will check for a combination with key modifiers. For example:

if (e.Key == Key.A && Keyboard.Modifiers == ModifierKeys.Control)
                {
                            // MyCommand Executed
                }
 
Will that approach suit your needs ? 

Regards,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Vitrum
Top achievements
Rank 1
answered on 01 Jun 2013, 01:53 AM
it works.
0
Silviu
Top achievements
Rank 1
answered on 12 May 2014, 12:10 PM
Hello Thomas,
Best approach is to set command key binding in your content control (e.g. Window):

<Window.InputBindings>
    <KeyBinding Key="A" Modifiers="Ctrl" Command="{Binding MyCommand}" />
</Window.InputBindings>

Then in the RadGridView set key binding the following way:

<telerik:RadGridView.InputBindings>
    <KeyBinding Modifiers="Control" Key="A" Command="ApplicationCommands.NotACommand" />
</telerik:RadGridView.InputBindings>

Best wishes,
S

Tags
GridView
Asked by
Thomas
Top achievements
Rank 2
Answers by
Maya
Telerik team
Vitrum
Top achievements
Rank 1
Silviu
Top achievements
Rank 1
Share this question
or