mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Selection in MapItemsControl
This commit is contained in:
parent
ec13ed260d
commit
d296600b9e
6 changed files with 194 additions and 17 deletions
|
|
@ -180,6 +180,7 @@
|
|||
<Compile Include="Map.WPF.cs" />
|
||||
<Compile Include="MapBase.WPF.cs" />
|
||||
<Compile Include="MapGraticule.WPF.cs" />
|
||||
<Compile Include="MapItemsControl.WPF.cs" />
|
||||
<Compile Include="MapMultiPolygon.WPF.cs" />
|
||||
<Compile Include="MapOverlay.WPF.cs" />
|
||||
<Compile Include="MapPanel.WPF.cs" />
|
||||
|
|
|
|||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="map:MapItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue