Updated MapContentControl, MapItem, MapPath

This commit is contained in:
ClemensFischer 2026-02-02 12:10:09 +01:00
parent 2dc7431c25
commit 7cfb80520b
18 changed files with 216 additions and 133 deletions

View file

@ -1,15 +1,43 @@
#if UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
#else
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
#endif
namespace MapControl
{
public partial class MapContentControl
public partial class MapContentControl : ContentControl
{
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapContentControl, Location>(nameof(Location), null,
(control, oldValue, newValue) => MapPanel.SetLocation(control, newValue));
public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.Register<MapContentControl, bool>(nameof(AutoCollapse), false,
(control, oldValue, newValue) => MapPanel.SetAutoCollapse(control, newValue));
/// <summary>
/// Gets/sets MapPanel.Location.
/// </summary>
public Location Location
{
get => (Location)GetValue(LocationProperty);
set => SetValue(LocationProperty, value);
}
/// <summary>
/// Gets/sets MapPanel.AutoCollapse.
/// </summary>
public bool AutoCollapse
{
get => (bool)GetValue(AutoCollapseProperty);
set => SetValue(AutoCollapseProperty, value);
}
public MapContentControl()
{
DefaultStyleKey = typeof(MapContentControl);
@ -45,6 +73,9 @@ namespace MapControl
}
}
/// <summary>
/// MapContentControl with a Pushpin Style.
/// </summary>
public partial class Pushpin : MapContentControl
{
public Pushpin()

View file

@ -16,6 +16,18 @@ namespace MapControl
{
public partial class MapItem
{
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapItem, Location>(nameof(Location), null,
(item, oldValue, newValue) =>
{
MapPanel.SetLocation(item, newValue);
item.UpdateMapTransform();
});
public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.Register<MapItem, bool>(nameof(AutoCollapse), false,
(item, oldValue, newValue) => MapPanel.SetAutoCollapse(item, newValue));
private Windows.Foundation.Point? pointerPressedPosition;
public MapItem()

View file

@ -1,8 +1,6 @@
#if UWP
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
#else
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Shapes;
#endif
@ -14,17 +12,5 @@ namespace MapControl
{
MapPanel.InitMapElement(this);
}
private void SetDataTransform(Matrix matrix)
{
if (Data.Transform is MatrixTransform transform)
{
transform.Matrix = matrix;
}
else
{
Data.Transform = new MatrixTransform { Matrix = matrix };
}
}
}
}