// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
#if WINDOWS_UWP
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
#else
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
#endif
namespace MapControl
{
///
/// Container class for an item in a MapItemsControl.
///
public partial class MapItem : ListBoxItem
{
public static readonly DependencyProperty LocationMemberPathProperty = DependencyProperty.Register(
nameof(LocationMemberPath), typeof(string), typeof(MapItem),
new PropertyMetadata(null, (o, e) => BindingOperations.SetBinding(
o, LocationProperty, new Binding { Path = new PropertyPath((string)e.NewValue) })));
///
/// Gets/sets MapPanel.AutoCollapse.
///
public bool AutoCollapse
{
get { return (bool)GetValue(AutoCollapseProperty); }
set { SetValue(AutoCollapseProperty, value); }
}
///
/// Gets/sets MapPanel.Location.
///
public Location Location
{
get { return (Location)GetValue(LocationProperty); }
set { SetValue(LocationProperty, value); }
}
///
/// Path to a source property for binding the Location property.
///
public string LocationMemberPath
{
get { return (string)GetValue(LocationMemberPathProperty); }
set { SetValue(LocationMemberPathProperty, value); }
}
}
///
/// Manages a collection of selectable items on a Map.
///
public partial class MapItemsControl : ListBox
{
protected override DependencyObject GetContainerForItemOverride()
{
return new MapItem();
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is MapItem;
}
public void SelectItems(Predicate