mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Added DependencyPropertyHelper.AddOwner
This commit is contained in:
parent
f78bcb33fa
commit
a3d25b5084
12 changed files with 119 additions and 133 deletions
|
|
@ -40,5 +40,20 @@ namespace MapControl
|
|||
|
||||
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
|
||||
}
|
||||
|
||||
public static DependencyProperty AddOwner<TOwner, TValue>(
|
||||
string name,
|
||||
DependencyProperty source,
|
||||
Action<TOwner, TValue, TValue> changed = null)
|
||||
where TOwner : DependencyObject
|
||||
{
|
||||
var metadata = new PropertyMetadata(default, (o, e) =>
|
||||
{
|
||||
o.SetValue(source, e.NewValue);
|
||||
changed?.Invoke((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue);
|
||||
});
|
||||
|
||||
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,15 @@
|
|||
#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 : ContentControl
|
||||
public partial class MapContentControl
|
||||
{
|
||||
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);
|
||||
|
|
@ -73,10 +45,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MapContentControl with a Pushpin Style.
|
||||
/// </summary>
|
||||
public partial class Pushpin : MapContentControl
|
||||
public partial class Pushpin
|
||||
{
|
||||
public Pushpin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,18 +16,6 @@ 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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue