Panning with Mouse Middle Button

How Can I pan in the diagram with Mouse Middle button pressed instead of Left Mouse button pressed?

I’m assuming you are using WPF, not Silverlight:

public class MiddlePanningTool : PanningTool { public override bool CanStart() { Diagram diagram = this.Diagram;</p><p> if (diagram == null) return false; if (!diagram.AllowScroll) return false;</p><p> // require left button & that it has moved far enough away from the mouse down point, so it isn't a click if (!IsMiddleButtonDown()) return false;</p><p> // don't include the following check when this tool is running modally if (diagram.CurrentTool != this) { // mouse needs to have moved from the mouse-down point if (!IsBeyondDragSize()) return false; }</p><p> return true; }</p><p> private bool IsMiddleButtonDown() { Diagram diagram = this.Diagram; if (diagram == null) return false; MouseEventArgs mea = diagram.LastMouseEventArgs; if (mea != null && mea.MiddleButton == MouseButtonState.Pressed) return true; MouseButtonEventArgs mbea = diagram.LastMouseEventArgs as MouseButtonEventArgs; if (mbea != null && mbea.ChangedButton == MouseButton.Middle) return true; return false; } }


Install by replacing the Diagram.PanningTool, either in XAML or in code.

The advantage of using the middle mouse button is that it no longer conflicts with other tools such as the DragSelectingTool, which no longer would need to be disabled or replaced with null. The disadvantage is that most users don’t know about using the middle mouse button as a regular button while dragging – they only know that it rotates and maybe that it clicks.

Thanks Walter, you are a Star Star