XAML-Map-Control/MapControl/WPF/MapPanel.WPF.cs

31 lines
1 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System.Windows;
namespace MapControl
{
public partial class MapPanel
{
private static readonly DependencyPropertyKey ParentMapPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
"ParentMap", typeof(MapBase), typeof(MapPanel), new FrameworkPropertyMetadata(
null, FrameworkPropertyMetadataOptions.Inherits, ParentMapPropertyChanged));
public static readonly DependencyProperty ParentMapProperty = ParentMapPropertyKey.DependencyProperty;
2017-09-05 20:57:17 +02:00
public static MapBase GetParentMap(UIElement element)
{
2017-09-05 20:57:17 +02:00
return (MapBase)element.GetValue(ParentMapProperty);
}
2017-09-05 20:57:17 +02:00
public static void InitMapElement(FrameworkElement element)
{
2017-09-05 20:57:17 +02:00
if (element is MapBase)
{
element.SetValue(ParentMapPropertyKey, element);
}
}
}
}