diff --git a/MapControl/Avalonia/MapItem.Avalonia.cs b/MapControl/Avalonia/MapItem.Avalonia.cs
index 44a52318..64fb4648 100644
--- a/MapControl/Avalonia/MapItem.Avalonia.cs
+++ b/MapControl/Avalonia/MapItem.Avalonia.cs
@@ -10,20 +10,17 @@
(item, oldValue, newValue) => item.UpdateMapTransform(newValue));
///
- /// Replaces ListBoxItem pointer event handling by not calling base.OnPointerPressed.
- /// Setting e.Handled = true generates a PointerReleased event in the parent MapItemsControl,
- /// which resembles the behavior of the ListBox base class.
+ /// Prevent range selection by Shift+PointerPressed.
///
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
- if (!e.Handled)
+ if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
{
e.Handled = true;
-
- if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
- {
- mapItemsControl.OnItemClicked(this, e.KeyModifiers.HasFlag(KeyModifiers.Control));
- }
+ }
+ else
+ {
+ base.OnPointerPressed(e);
}
}
}
diff --git a/MapControl/Shared/MapItemsControl.cs b/MapControl/Shared/MapItemsControl.cs
index ea2ad0f6..88229075 100644
--- a/MapControl/Shared/MapItemsControl.cs
+++ b/MapControl/Shared/MapItemsControl.cs
@@ -78,41 +78,5 @@ namespace MapControl
{
SelectItemsByPosition(rect.Contains);
}
-
- protected internal void OnItemClicked(MapItem mapItem, bool controlKeyPressed)
- {
- var item = ItemFromContainer(mapItem);
-
- if (SelectionMode == SelectionMode.Single)
- {
- if (SelectedItem != item)
- {
- SelectedItem = item;
- }
- else if (controlKeyPressed)
- {
- SelectedItem = null;
- }
- }
- else if (
-#if !AVALONIA
- SelectionMode == SelectionMode.Multiple ||
-#endif
- controlKeyPressed)
- {
- if (SelectedItems.Contains(item))
- {
- SelectedItems.Remove(item);
- }
- else
- {
- SelectedItems.Add(item);
- }
- }
- else
- {
- ResetSelectedItems(item);
- }
- }
}
}
diff --git a/MapControl/WPF/MapItem.WPF.cs b/MapControl/WPF/MapItem.WPF.cs
index 1a6479f1..acb86147 100644
--- a/MapControl/WPF/MapItem.WPF.cs
+++ b/MapControl/WPF/MapItem.WPF.cs
@@ -1,5 +1,4 @@
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Input;
namespace MapControl
@@ -19,31 +18,18 @@ namespace MapControl
}
///
- /// Replaces ListBoxItem mouse event handling by not calling base.OnMouseLeftButtonDown.
- /// Setting e.Handled = true generates a MouseLeftButtonUp event in the parent MapItemsControl,
- /// which resembles the behavior of the ListBox base class.
+ /// Prevent range selection by Shift+MouseLeftButtonDown.
///
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
- if (!e.Handled)
+ if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
{
e.Handled = true;
-
- if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
- {
- mapItemsControl.OnItemClicked(this, Keyboard.Modifiers.HasFlag(ModifierKeys.Control));
- }
}
- }
-
- ///
- /// Replaces ListBoxItem mouse event handling by not calling base.OnMouseRightButtonDown.
- /// Setting e.Handled = true generates a MouseRightButtonUp event in the parent MapItemsControl,
- /// which resembles the behavior of the ListBox base class.
- ///
- protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
- {
- OnMouseLeftButtonDown(e);
+ else
+ {
+ base.OnMouseLeftButtonDown(e);
+ }
}
}
}
diff --git a/MapControl/WinUI/MapItem.WinUI.cs b/MapControl/WinUI/MapItem.WinUI.cs
index 1f703776..0f775a73 100644
--- a/MapControl/WinUI/MapItem.WinUI.cs
+++ b/MapControl/WinUI/MapItem.WinUI.cs
@@ -1,12 +1,10 @@
using Windows.System;
#if UWP
using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
#else
using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
#endif
@@ -34,21 +32,17 @@ namespace MapControl
}
///
- /// Replaces ListBoxItem pointer event handling by not calling base.OnPointerPressed.
- /// Setting e.Handled = true generates a PointerReleased event in the parent MapItemsControl,
- /// which differs from the behavior of the ListBox base class, where neither a PointerPressed
- /// nor a PointerReleased is generated.
+ /// Prevent range selection by Shift+PointerPressed.
///
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
- if (!e.Handled)
+ if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
{
e.Handled = true;
-
- if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
- {
- mapItemsControl.OnItemClicked(this, e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control));
- }
+ }
+ else
+ {
+ base.OnPointerPressed(e);
}
}