CanIncreaseZoom issue

I’m using the regular CommandHandler, not a custom one. I’m also using GoXam for Silverlight v1.2.2 with Silverlight 4. What I’m seeing is that CanIncreaseZoom and CanDecreaseZoom always return the same value once the diagram has been initialized. This issue manifests in two ways:

  1. If a Diagram is created with a control template that specifies a value for DiagramPanel.MinimumScale and the value of Diagram.InitialScale has an equal value, then CanDecreaseZoom will always return false. User interface elements that should initially be disabled never get a chance to enable.

  2. If a Diagram is created with a control template that specifies a value for DiagramPanel.MinimumScale and the value of Diagram.InitialScale has a greater value, then CanDecreaseZoom will always return true. Calling DecreaseZoomCommand.Execute thankfully does not decrease the DiagramPanel.Scale past the minimum value, but user interface elements remain enabled when they should disable.

The crux of the problem seems to be that the implementation of CommandHandler.ZoomCoomand never fires the ICommand.CanExecuteChanged event.

I assume I’m going to have this problem with all of the other ICommands on CommandHandler. This seems like a serious bug.

Yes, that seems to be a bug with the DiagramPanel.Scale/MinimumScale/MaximumScale property setters. We’ll fix this for the next release. Thanks for reporting it.

It isn’t a problem with the commands not related to Scale.
For example, in the UpdateDemo sample you can see that the Undo and Redo buttons enable and disable correctly.

For now, you can implement a work-around by changing some command-related Diagram properties when the DiagramPanel.Scale changes:

private double prevScale = 0;

myDiagram.TemplateApplied += (sndr, evt) => {
prevScale = myDiagram.Panel.Scale;

myDiagram.Panel.ViewportBoundsChanged += (s, e) => {
  // detect when the Scale has changed
  if (myDiagram.Panel.Scale != prevScale) {
    prevScale = myDiagram.Panel.Scale;
    myDiagram.AllowZoom = false;  // this should raise ICommand.CanExecuteChanged events
    myDiagram.AllowZoom = true;
  }
};

};

Thanks for the work around! I’m glad it’s limited to just the Scale related commands.