diff --git a/MapControl/WinUI/Map.WinUI.cs b/MapControl/WinUI/Map.WinUI.cs index 9f8eff2c..360e1e80 100644 --- a/MapControl/WinUI/Map.WinUI.cs +++ b/MapControl/WinUI/Map.WinUI.cs @@ -21,7 +21,7 @@ namespace MapControl DependencyPropertyHelper.Register(nameof(MouseWheelZoomDelta), 0.25); private double mouseWheelDelta; - private bool manipulationEnabled; + private bool? manipulationEnabled; public Map() { @@ -34,6 +34,7 @@ namespace MapControl ManipulationDelta += OnManipulationDelta; ManipulationCompleted += OnManipulationCompleted; PointerPressed += OnPointerPressed; + PointerMoved += OnPointerMoved; PointerWheelChanged += OnPointerWheelChanged; } @@ -49,7 +50,7 @@ namespace MapControl private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { - if (manipulationEnabled) + if (manipulationEnabled.HasValue && manipulationEnabled.Value) { if (e.PointerDeviceType == PointerDeviceType.Mouse) { @@ -64,7 +65,7 @@ namespace MapControl private void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { - manipulationEnabled = false; + manipulationEnabled = null; } private void OnPointerPressed(object sender, PointerRoutedEventArgs e) @@ -76,6 +77,17 @@ namespace MapControl e.KeyModifiers == VirtualKeyModifiers.None; } + private void OnPointerMoved(object sender, PointerRoutedEventArgs e) + { + // Set manipulationEnabled when no PointerPressed was received. + // + if (!manipulationEnabled.HasValue && + e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) + { + manipulationEnabled = e.KeyModifiers == VirtualKeyModifiers.None; + } + } + private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) diff --git a/MapControl/WinUI/MapItem.WinUI.cs b/MapControl/WinUI/MapItem.WinUI.cs index 9be45c94..66ce37b4 100644 --- a/MapControl/WinUI/MapItem.WinUI.cs +++ b/MapControl/WinUI/MapItem.WinUI.cs @@ -45,11 +45,6 @@ namespace MapControl pointerPressedPosition = e.GetCurrentPoint(null).Position; base.OnPointerPressed(e); - - // Unsetting e.Handled enables PointerPressed event handlers - // and PointerPressed handling in class Map. - // - e.Handled = false; } protected override void OnPointerReleased(PointerRoutedEventArgs e) @@ -71,9 +66,7 @@ namespace MapControl } } - // Unsetting e.Handled enables PointerReleased event handlers. - // - e.Handled = false; + e.Handled = true; } protected override void OnApplyTemplate()