mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
MapItem mouse/pointer event handling
This commit is contained in:
parent
417d4c8987
commit
fc242ee7a4
|
|
@ -9,10 +9,19 @@
|
|||
DependencyPropertyHelper.AddOwner<MapItem, Location>(MapPanel.LocationProperty, null,
|
||||
(item, oldValue, newValue) => item.UpdateMapTransform(newValue));
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
(ItemsControl.ItemsControlFromItemContainer(this) as MapItemsControl)?
|
||||
.OnItemClicked(this, e.KeyModifiers.HasFlag(KeyModifiers.Control));
|
||||
if (!e.Handled)
|
||||
{
|
||||
e.Handled = true;
|
||||
(ItemsControl.ItemsControlFromItemContainer(this) as MapItemsControl)?
|
||||
.OnItemClicked(this, e.KeyModifiers.HasFlag(KeyModifiers.Control));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@ namespace MapControl
|
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
// Prevent default handling in ListBoxItem by not calling base.OnMouseLeftButtonDown.
|
||||
if (!e.Handled)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
|
@ -29,9 +33,13 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
// Prevent default handling in ListBoxItem by not calling base.OnMouseRightButtonDown.
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,14 @@ namespace MapControl
|
|||
MapPanel.InitMapElement(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
protected override void OnPointerPressed(PointerRoutedEventArgs e)
|
||||
{
|
||||
// Prevent default handling in ListBoxItem by not calling base.OnPointerPressed.
|
||||
if (!e.Handled)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
|
@ -44,12 +49,6 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnPointerReleased(PointerRoutedEventArgs e)
|
||||
{
|
||||
// Prevent default handling in ListBoxItem by not calling base.OnPointerReleased.
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
|
|
|||
Loading…
Reference in a new issue