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

@ -137,7 +137,8 @@
<map:MapItemsControl ItemContainerStyle="{StaticResource PushpinItemStyle}"
ItemsSource="{Binding Pushpins}"
SelectedItem="{Binding SelectedPushpin}"
SelectionMode="Multiple"/>
SelectionMode="Multiple"
SelectionChanged="MapItemsControlSelectionChanged"/>
<map:Pushpin AutoCollapse="True" Location="65,-18" Content="Iceland"/>
<map:Pushpin AutoCollapse="True" Location="71,25" Content="Norway"/>

View file

@ -6,6 +6,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
@ -20,7 +21,7 @@ namespace SampleApplication
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
//TileImageLoader.Cache = new RedisCache(Options.Create(new RedisCacheOptions
//{
// Configuration = "localhost:6379",
// Configuration = "T400:6379",
// InstanceName = "MapTileCache/"
//}));
@ -82,6 +83,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 ResetHeadingButtonClick(object sender, RoutedEventArgs e)
{
map.TargetHeading = 0d;