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
|
|
@ -104,10 +104,25 @@ namespace MapControl
|
|||
|
||||
public static DependencyProperty AddOwner<TOwner, TValue>(
|
||||
DependencyProperty source,
|
||||
Action<TOwner, TValue, TValue> changed = null) where TOwner : DependencyObject
|
||||
Action<TOwner, TValue, TValue> changed) where TOwner : DependencyObject
|
||||
{
|
||||
return source.AddOwner(typeof(TOwner), new FrameworkPropertyMetadata(
|
||||
(o, e) => changed((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue)));
|
||||
}
|
||||
|
||||
public static DependencyProperty AddOwner<TOwner, TValue>(
|
||||
string _, // for compatibility with WinUI/UWP DependencyPropertyHelper
|
||||
DependencyProperty source) where TOwner : DependencyObject
|
||||
{
|
||||
return AddOwner<TOwner, TValue>(source);
|
||||
}
|
||||
|
||||
public static DependencyProperty AddOwner<TOwner, TValue>(
|
||||
string _, // for compatibility with WinUI/UWP DependencyPropertyHelper
|
||||
DependencyProperty source,
|
||||
Action<TOwner, TValue, TValue> changed) where TOwner : DependencyObject
|
||||
{
|
||||
return AddOwner(source, changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,16 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// ContentControl placed on a MapPanel at a geographic location specified by the Location property.
|
||||
/// </summary>
|
||||
public class MapContentControl : ContentControl
|
||||
public partial class MapContentControl
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, Location>(MapPanel.LocationProperty);
|
||||
|
||||
public static readonly DependencyProperty AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, bool>(MapPanel.AutoCollapseProperty);
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
static MapContentControl()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapContentControl), new FrameworkPropertyMetadata(typeof(MapContentControl)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MapContentControl with a Pushpin Style.
|
||||
/// </summary>
|
||||
public class Pushpin : MapContentControl
|
||||
public partial class Pushpin
|
||||
{
|
||||
static Pushpin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapItem
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, Location>(MapPanel.LocationProperty,
|
||||
(item, oldValue, newValue) => item.UpdateMapTransform());
|
||||
|
||||
public static readonly DependencyProperty AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, bool>(MapPanel.AutoCollapseProperty);
|
||||
|
||||
static MapItem()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue