No "AllowDuplicate" option

3 posts, 0 answers
  1. Terry
    Terry avatar
    17 posts
    Member since:
    Mar 2013

    Posted 21 Nov 2013 Link to this post

    The RadDiagram lets you turn off Cut, Copy, Paste, etc functionality, but there doesn't seem to be a way to turn off the Duplicate command.

    How would I remove the Ctrl+D key binding from the RadDiagram?

    Thanks
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 26 Nov 2013 Link to this post

    Hi Terry,

    In order to achieve your requirement you actually can predefine the duplicate command that has been executed on Ctrl+D combination. You can do this with the following snippet:

    private static void CanExecuteDuplicate(object sender, CanExecuteRoutedEventArgs e)
    {
        e.CanExecute = true;
    }
     
    private static void ExecuteDuplicate(object sender, ExecutedRoutedEventArgs e)
    {
        return;
    }
     
    static MainWindow()
    {
        var duplicate = new CommandBinding(DiagramCommands.Duplicate, ExecuteDuplicate, CanExecuteDuplicate);
        CommandManager.RegisterClassCommandBinding(typeof(RadDiagram), duplicate);
    }
    By doing so you will need to implement custom duplication logic inside the ExecuteDuplicate() method. Please note that this method will be invoked when the e.CanExecute is set to True, otherwise the default duplication logic will be triggered.

    Please give this approach a try and let us know if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Terry
    Terry avatar
    17 posts
    Member since:
    Mar 2013

    Posted 26 Nov 2013 Link to this post

    Thank you! That worked like a charm
Back to Top