Added Avalonia MapContentControl

This commit is contained in:
ClemensFischer 2024-05-25 00:13:14 +02:00
parent 1e7dd235ef
commit 33cb30c570
2 changed files with 56 additions and 0 deletions

View file

@ -61,5 +61,12 @@ namespace MapControl
{
return property.AddOwner<TOwner>();
}
public static StyledProperty<TValue> AddOwner<TOwner, TValue>(
AvaloniaProperty property)
where TOwner : AvaloniaObject
{
return AddOwner<TOwner, TValue>((StyledProperty<TValue>)property);
}
}
}

View file

@ -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
{
/// <summary>
/// ContentControl placed on a MapPanel at a geographic location specified by the Location property.
/// </summary>
public class MapContentControl : ContentControl
{
public static readonly StyledProperty<bool> AutoCollapseProperty =
DependencyPropertyHelper.AddOwner<MapContentControl, bool>(MapPanel.AutoCollapseProperty);
public static readonly StyledProperty<Location> LocationProperty =
DependencyPropertyHelper.AddOwner<MapContentControl, Location>(MapPanel.LocationProperty);
protected override Type StyleKeyOverride => typeof(MapContentControl);
/// <summary>
/// Gets/sets MapPanel.AutoCollapse.
/// </summary>
public bool AutoCollapse
{
get => GetValue(AutoCollapseProperty);
set => SetValue(AutoCollapseProperty, value);
}
/// <summary>
/// Gets/sets MapPanel.Location.
/// </summary>
public Location Location
{
get => GetValue(LocationProperty);
set => SetValue(LocationProperty, value);
}
}
/// <summary>
/// MapContentControl with a Pushpin Style.
/// </summary>
public class Pushpin : MapContentControl
{
protected override Type StyleKeyOverride => typeof(Pushpin);
}
}