Override keyboard copy/paste controls

3 posts, 0 answers
  1. Zak
    Zak avatar
    2 posts
    Member since:
    Jul 2014

    Posted 11 Aug 2014 Link to this post


    I'd like to override the keyboard shortcuts for copy, cut and paste because there are some very specific things that I need to do to copy/paste my objects. I've tried overriding the OnKeyDown event, but the commands never hit that method, even though other ctrl commands (ex. ctrl+s) do. Is there a way to have this this control returned to me when I set AllowCopy, AllowCut and AllowPaste to False?

  2. Zarko
    Zarko avatar
    755 posts

    Posted 12 Aug 2014 Link to this post

    Hi Zak,
    Could you please elaborate a little bit more on what exactly are you trying to achieve ? There are a couple of ways to override the default copy, cut and paste commands but it depends on your specific scenario:
    1) You could add your own command binding for those commands:
    static Example()
        var copyBinding = new CommandBinding(DiagramCommands.Copy, OnCopyExecute, OnCanCopy);
        CommandManager.RegisterClassCommandBinding(typeof(RadDiagram), copyBinding);
    private static void OnCanCopy(object sender, CanExecuteRoutedEventArgs e)
        e.CanExecute = true;
        e.Handled = true;
    private static void OnCopyExecute(object sender, ExecutedRoutedEventArgs e)
        // Do what you want.
    2) You could override the Ctr + C (Ctr + V and Ctr + X) input bindings with an ApplicationCommands.NotACommand and this way they will be ignored and the key down events will be rised:
    public Example()
        CommandManager.RegisterClassInputBinding(typeof(RadDiagram), new InputBinding(ApplicationCommands.NotACommand, new KeyGesture(Key.C, ModifierKeys.Control)));
    I hope I was able to help you and if you have more questions feel free to ask.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. Zak
    Zak avatar
    2 posts
    Member since:
    Jul 2014

    Posted 12 Aug 2014 in reply to Zarko Link to this post

    Those worked perfectly! Thank you very much!
Back to Top