using Avalonia; using Avalonia.Controls; using Avalonia.Input; namespace MapControl { public partial class MapItem { public static readonly StyledProperty AutoCollapseProperty = MapPanel.AutoCollapseProperty.AddOwner(); public static readonly StyledProperty LocationProperty = MapPanel.LocationProperty.AddOwner(); static MapItem() { LocationProperty.Changed.AddClassHandler((item, e) => item.UpdateMapTransform()); } protected override void OnPointerPressed(PointerPressedEventArgs e) { if (e.Pointer.Type != PointerType.Mouse && ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl) { mapItemsControl.UpdateSelection(this, e); } e.Handled = true; } protected override void OnPointerReleased(PointerReleasedEventArgs e) { if (e.Pointer.Type == PointerType.Mouse && e.InitialPressMouseButton == MouseButton.Left && ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl) { mapItemsControl.UpdateSelection(this, e); } e.Handled = true; } } }