MapItemsControl SelectionChanged handling in sample applications

This commit is contained in:
ClemensFischer 2024-05-31 10:40:29 +02:00
parent f78e7e73c4
commit 70bc9b89ac
7 changed files with 25 additions and 3 deletions

View file

@ -19,6 +19,7 @@
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
SelectedItem="{Binding SelectedPushpin}"
SelectionMode="Multiple"
SelectionChanged="MapItemsControlSelectionChanged"
DoubleTapped="MapItemsControlDoubleTapped">
<map:MapItemsControl.Styles>
<Style Selector="map|MapItem">

View file

@ -4,7 +4,9 @@ using Avalonia.Media;
using MapControl;
using MapControl.UiTools;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace SampleApplication
{
@ -72,6 +74,11 @@ namespace SampleApplication
partial void AddTestLayers();
private void MapItemsControlSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
Debug.WriteLine("SelectedItems: " + string.Join(", ", ((MapItemsControl)sender).SelectedItems.OfType<PointItem>().Select(item => item.Name)));
}
private void MapItemsControlDoubleTapped(object sender, TappedEventArgs e)
{
e.Handled = true; // prevent MapDoubleTapped