Could you tell me how to receive Ctrl+G in my window ?

I suspect that the diagram handle this event bebore I can use it…


You’re using WPF, aren’t you?

You can replace the Diagram.CommandBindings and InputBindings as you see fit.

(If it were in Silverlight, you would need to override CommandHandler.DoKeyDown and replace the standard Diagram.CommandHandler.)

Yes, i’m using WPF.

My user control binds a command which uses Ctrl+G gesture

                        <CommandBinding Command="v6:Commands.GroupVariablesInGroupCommand"
                                        Executed="ExecuteGroupVariablesInGroupCommand" CanExecute="CanExecuteGroupVariablesInGroupCommand"/>

When the focus is not on the diagram, my “ctrl+G” shorcut works as expected.

I add the same command on the diagram :

                        <CommandBinding Command="v6:Commands.GroupVariablesInGroupCommand"
                                        Executed="ExecuteGroupVariablesInGroupCommand" CanExecute="CanExecuteGroupVariablesInGroupCommand"/>

But, no Ctrl+G on diagram…

I tried to add Inputbinding

                        <KeyBinding Gesture="Ctrl+G" Command="v6:Commands.GroupVariablesInGroupCommand"/>

But, no Ctrl+G on diagram…

Is there an other way ?

I’ve found a new way.

I override “CanGroup” and “Group” in my CommandHandler to call my methods.


I was just suggesting that you replace the CommandBinding by removing the one we define and by adding your own. You had done the the second part, but hadn’t done the first part.

But your alternative solution, overriding methods on CommandHandler, will work fine too. It’s just that anything looking at the commands will see something about "Group"ing, not about whatever it is that you want to substitute.

Sorry to resurrect an old thread, but I’m curious: how exactly would one remove one of the standard CommandBindings that are defined as part of the Diagram and replace it with your own? I’ve run into this same problem and the solution is not obvious to me (probably because I’ve dealt mostly with Silverlight, but am now working on a pure WPF project).

Modify the Diagram.CommandBindings (and/or the Diagram.InputBindings) collections.

Right, but when do those collections get populated? I tried catch the Diagram.Loaded and Diagram.TemplateApplied events, but the Diagram.CommandBindings collection was empty at both of those points (hence there was nothing to remove).