From 33cb30c5703030a0d5aec646f4910eda71b1dd4d Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Sat, 25 May 2024 00:13:14 +0200 Subject: [PATCH] Added Avalonia MapContentControl --- .../DependencyPropertyHelper.Avalonia.cs | 7 +++ .../Avalonia/MapContentControl.Avalonia.cs | 49 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 MapControl/Avalonia/MapContentControl.Avalonia.cs diff --git a/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs b/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs index 35ad2773..a41ebe03 100644 --- a/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs +++ b/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs @@ -61,5 +61,12 @@ namespace MapControl { return property.AddOwner(); } + + public static StyledProperty AddOwner( + AvaloniaProperty property) + where TOwner : AvaloniaObject + { + return AddOwner((StyledProperty)property); + } } } diff --git a/MapControl/Avalonia/MapContentControl.Avalonia.cs b/MapControl/Avalonia/MapContentControl.Avalonia.cs new file mode 100644 index 00000000..a925fd90 --- /dev/null +++ b/MapControl/Avalonia/MapContentControl.Avalonia.cs @@ -0,0 +1,49 @@ +// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control +// Copyright © 2024 Clemens Fischer +// Licensed under the Microsoft Public License (Ms-PL) + +using Avalonia.Controls; +using System; + +namespace MapControl +{ + /// + /// ContentControl placed on a MapPanel at a geographic location specified by the Location property. + /// + public class MapContentControl : ContentControl + { + public static readonly StyledProperty AutoCollapseProperty = + DependencyPropertyHelper.AddOwner(MapPanel.AutoCollapseProperty); + + public static readonly StyledProperty LocationProperty = + DependencyPropertyHelper.AddOwner(MapPanel.LocationProperty); + + protected override Type StyleKeyOverride => typeof(MapContentControl); + + /// + /// Gets/sets MapPanel.AutoCollapse. + /// + public bool AutoCollapse + { + get => GetValue(AutoCollapseProperty); + set => SetValue(AutoCollapseProperty, value); + } + + /// + /// Gets/sets MapPanel.Location. + /// + public Location Location + { + get => GetValue(LocationProperty); + set => SetValue(LocationProperty, value); + } + } + + /// + /// MapContentControl with a Pushpin Style. + /// + public class Pushpin : MapContentControl + { + protected override Type StyleKeyOverride => typeof(Pushpin); + } +}