I'm looking for a way to pan using the middle mouse button. In ArcMap you can pan around the map while being in a selection mode and I want the same behavior in my WPF application.
I have found a few other questions that ask the same thing, but are not really answered.
Is there any way to do this using the Runtime SDK for .NET?
Solved! Go to Solution.
How's this:
var peer = new Esri.ArcGISRuntime.UI.Controls.MapViewAutomationPeer(mapView);
Point? start = null;
mapView.MouseDown += (s, e) =>
{
if (e.ChangedButton == MouseButton.Middle)
start = e.GetPosition(mapView);
};
mapView.MouseUp += (s, e) =>
{
if (e.ChangedButton == MouseButton.Middle)
{
start = null;
peer.Complete();
}
};
mapView.PreviewMouseMove += (s, e) =>
{
if (e.MiddleButton == MouseButtonState.Pressed && start.HasValue)
{
var p = e.GetPosition(mapView);
peer.Pan(p.X - start.Value.X, p.Y - start.Value.Y);
start = p;
}
};
How's this:
var peer = new Esri.ArcGISRuntime.UI.Controls.MapViewAutomationPeer(mapView);
Point? start = null;
mapView.MouseDown += (s, e) =>
{
if (e.ChangedButton == MouseButton.Middle)
start = e.GetPosition(mapView);
};
mapView.MouseUp += (s, e) =>
{
if (e.ChangedButton == MouseButton.Middle)
{
start = null;
peer.Complete();
}
};
mapView.PreviewMouseMove += (s, e) =>
{
if (e.MiddleButton == MouseButtonState.Pressed && start.HasValue)
{
var p = e.GetPosition(mapView);
peer.Pan(p.X - start.Value.X, p.Y - start.Value.Y);
start = p;
}
};