CanIncreaseZoom not called by mouse wheel

I created a custom command handler by deriving from CommandHandler. I then overrode CanIncreaseZoom and simply called base.CanIncreaseZoom(). Setting a breakpoint on this method shows that it is never called when zooming with the mouse wheel. Cracking open the assembly with Reflector confirms that DiagramTool.StandardMouseWheel() blindly calls this.Diagram.CommandHandler.IncreaseZoom() without first checking CanIncreaseZoom. Same thing applies to CanDecreaseZoom.

That’s correct – the Can… predicate is called by the WPF command mechanism to determine whether the command should be enabled or grayed out or whatever. In your example, it’s called by the CommandBinding for Commands.IncreaseZoom.

So the implementation of those commands need not call those Can… methods.

On the other hand, for Silverlight and in DiagramTool.StandardMouseWheel perhaps we should be calling those predicates as part of the event handlers that are deciding which command to invoke. Thanks for the suggestion.