Ignoring CTRL+(key) press in RadGridView

4 posts, 0 answers
  1. Thomas
    Thomas avatar
    17 posts
    Member since:
    Oct 2012

    Posted 21 Feb 2012 Link to this post

    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:

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

    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).
  2. Maya
    Maya avatar
    4062 posts

    Posted 24 Feb 2012 Link to this post

    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 ? 

    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Vitrum
    Vitrum avatar
    3 posts
    Member since:
    Jun 2009

    Posted 31 May 2013 Link to this post

    it works.
  5. Silviu
    Silviu avatar
    1 posts
    Member since:
    Nov 2013

    Posted 12 May 2014 Link to this post

    Hello Thomas,
    Best approach is to set command key binding in your content control (e.g. Window):

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

    Then in the RadGridView set key binding the following way:

        <KeyBinding Modifiers="Control" Key="A" Command="ApplicationCommands.NotACommand" />

    Best wishes,

Back to Top