mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Revert to default ListBox mouse event handling
This commit is contained in:
parent
584dcd7bb4
commit
70fd58d418
4 changed files with 18 additions and 77 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MapControl
|
||||
|
|
@ -19,31 +18,18 @@ namespace MapControl
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
OnMouseLeftButtonDown(e);
|
||||
else
|
||||
{
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue