mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Selection in MapItemsControl
This commit is contained in:
parent
ec13ed260d
commit
d296600b9e
6 changed files with 194 additions and 17 deletions
49
MapControl/WPF/MapItemsControl.WPF.cs
Normal file
49
MapControl/WPF/MapItemsControl.WPF.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2018 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
public class MapItem : ListBoxItem
|
||||
{
|
||||
public MapItem()
|
||||
{
|
||||
DefaultStyleKey = typeof(MapItem);
|
||||
|
||||
MapPanel.InitMapElement(this);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
(ItemsControl.ItemsControlFromItemContainer(this) as MapItemsControl)?.MapItemClicked(
|
||||
this, Keyboard.Modifiers.HasFlag(ModifierKeys.Control), Keyboard.Modifiers.HasFlag(ModifierKeys.Shift));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MapItemsControl
|
||||
{
|
||||
public MapItem MapItemFromItem(object item)
|
||||
{
|
||||
return (MapItem)ItemContainerGenerator.ContainerFromItem(item);
|
||||
}
|
||||
|
||||
public object ItemFromMapItem(MapItem mapItem)
|
||||
{
|
||||
return ItemContainerGenerator.ItemFromContainer(mapItem);
|
||||
}
|
||||
|
||||
public void SelectItemsInGeometry(Geometry geometry)
|
||||
{
|
||||
SelectItemsByPosition(p => geometry.FillContains(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue