// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace MapControl { /// /// ContentControl placed on a MapPanel at a geographic location specified by the Location property. /// public class MapContentControl : ContentControl { public static readonly DependencyProperty AutoCollapseProperty = DependencyProperty.Register( nameof(AutoCollapse), typeof(bool), typeof(MapContentControl), new PropertyMetadata(false, (o, e) => MapPanel.SetAutoCollapse((MapContentControl)o, (bool)e.NewValue))); public static readonly DependencyProperty LocationProperty = DependencyProperty.Register( nameof(Location), typeof(Location), typeof(MapContentControl), new PropertyMetadata(null, (o, e) => MapPanel.SetLocation((MapContentControl)o, (Location)e.NewValue))); public MapContentControl() { DefaultStyleKey = typeof(MapContentControl); MapPanel.InitMapElement(this); } /// /// 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); } } protected override void OnApplyTemplate() { base.OnApplyTemplate(); var parentMap = MapPanel.GetParentMap(this); if (parentMap != null) { this.ValidateProperty(BackgroundProperty, parentMap, nameof(MapBase.Background)); this.ValidateProperty(BorderBrushProperty, parentMap, nameof(MapBase.Foreground)); this.ValidateProperty(ForegroundProperty, parentMap, nameof(MapBase.Foreground)); } } } /// /// MapContentControl with a Pushpin Style. /// public class Pushpin : MapContentControl { public Pushpin() { DefaultStyleKey = typeof(Pushpin); } } }