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); + } +}