I’m trying to zoom the diagram buy clicking the “Zoom In” & “Zoom Out” button by binding these to IncreaseZoom & DecreaseZoom command respectively.
But, it is not working. Clicking these button doesn’t do anything. The buttons are disabled.
Another issue is, whenever I drag & drop a node to the diagram it repositions. Its kind of annoying. How do I disable the repositioning?
(Solved this by using HorizontalContentAlignment & VerticalContentAlignment set to “Stretch” value on go:Diagram)
That’s not how one uses CommandBinding – you’re trying to get the Button to handle the IncreaseZoom command by having it do nothing, which is probably what it would normally do anyway, since most people don’t want to zoom into a Button.
Since Buttons can get focus, you need to specify the CommandTarget.
This works well for me:
<Button Command="IncreaseZoom" CommandTarget="{Binding ElementName=myDiagram}">In</Button>
<Button Command="DecreaseZoom" CommandTarget="{Binding ElementName=myDiagram}">Out</Button>
Or this for the Diagram, where the focus doesn’t change: