mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-02-11 18:26:00 +01:00
DependencyPropertyHelper
This commit is contained in:
parent
bc12b388de
commit
b7afd27c91
|
|
@ -19,7 +19,7 @@ namespace MapControl.MBTiles
|
|||
public class MBTileLayer : MapTileLayer
|
||||
{
|
||||
public static readonly DependencyProperty FileProperty =
|
||||
DependencyPropertyHelper.Register<MBTileLayer, string>(nameof(File), null, false,
|
||||
DependencyPropertyHelper.Register<MBTileLayer, string>(nameof(File), null,
|
||||
async (layer, oldValue, newValue) => await layer.FilePropertyChanged(newValue));
|
||||
|
||||
public string File
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace MapControl
|
|||
public static AttachedProperty<TValue> RegisterAttached<TOwner, TValue>(
|
||||
string name,
|
||||
TValue defaultValue = default,
|
||||
bool inherits = false,
|
||||
Action<Control, TValue, TValue> changed = null)
|
||||
Action<Control, TValue, TValue> changed = null,
|
||||
bool inherits = false)
|
||||
where TOwner : AvaloniaObject
|
||||
{
|
||||
var property = AvaloniaProperty.RegisterAttached<TOwner, Control, TValue>(name, defaultValue, inherits);
|
||||
|
|
|
|||
|
|
@ -47,25 +47,27 @@ namespace MapControl
|
|||
DependencyPropertyHelper.RegisterAttached<MapPanel, bool>("AutoCollapse");
|
||||
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, Location>("Location", null, false,
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, Location>("Location", null,
|
||||
(element, oldValue, newValue) => (element.Parent as MapPanel)?.InvalidateArrange());
|
||||
|
||||
public static readonly DependencyProperty BoundingBoxProperty =
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, BoundingBox>("BoundingBox", null, false,
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, BoundingBox>("BoundingBox", null,
|
||||
(element, oldValue, newValue) => (element.Parent as MapPanel)?.InvalidateArrange());
|
||||
|
||||
private static readonly DependencyProperty ViewPositionProperty =
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, Point?>("ViewPosition");
|
||||
|
||||
private static readonly DependencyProperty ParentMapProperty =
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, MapBase>("ParentMap", null, true,
|
||||
(element, oldValue, newValue) =>
|
||||
{
|
||||
if (element is IMapElement mapElement)
|
||||
{
|
||||
mapElement.ParentMap = newValue;
|
||||
}
|
||||
});
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, MapBase>("ParentMap", null,
|
||||
(element, oldValue, newValue) => SetParentMap(element, newValue), true);
|
||||
|
||||
private static void SetParentMap(FrameworkElement element, MapBase parentMap)
|
||||
{
|
||||
if (element is IMapElement mapElement)
|
||||
{
|
||||
mapElement.ParentMap = parentMap;
|
||||
}
|
||||
}
|
||||
|
||||
private MapBase parentMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ namespace MapControl
|
|||
public static DependencyProperty RegisterAttached<TOwner, TValue>(
|
||||
string name,
|
||||
TValue defaultValue = default,
|
||||
bool inherits = false,
|
||||
Action<FrameworkElement, TValue, TValue> changed = null)
|
||||
Action<FrameworkElement, TValue, TValue> changed = null,
|
||||
bool inherits = false)
|
||||
where TOwner : DependencyObject
|
||||
{
|
||||
var metadata = new FrameworkPropertyMetadata
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace MapControl
|
|||
public static DependencyProperty RegisterAttached<TOwner, TValue>(
|
||||
string name,
|
||||
TValue defaultValue = default,
|
||||
bool inherits = false, // unused in WinUI/UWP
|
||||
Action<FrameworkElement, TValue, TValue> changed = null)
|
||||
Action<FrameworkElement, TValue, TValue> changed = null,
|
||||
bool inherits = false) // unused in WinUI/UWP
|
||||
where TOwner : DependencyObject
|
||||
{
|
||||
var metadata = changed != null
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace MapControl.UiTools
|
|||
}
|
||||
|
||||
public static readonly DependencyProperty MapProperty =
|
||||
DependencyPropertyHelper.Register<MapLayersMenuButton, MapBase>(nameof(Map), null, false,
|
||||
DependencyPropertyHelper.Register<MapLayersMenuButton, MapBase>(nameof(Map), null,
|
||||
(button, oldValue, newValue) => button.InitializeMenu());
|
||||
|
||||
public MapBase Map
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace MapControl.UiTools
|
|||
}
|
||||
|
||||
public static readonly DependencyProperty MapProperty =
|
||||
DependencyPropertyHelper.Register<MapProjectionsMenuButton, MapBase>(nameof(Map), null, false,
|
||||
DependencyPropertyHelper.Register<MapProjectionsMenuButton, MapBase>(nameof(Map), null,
|
||||
(button, oldValue, newValue) => button.InitializeMenu());
|
||||
|
||||
public MapBase Map
|
||||
|
|
|
|||
Loading…
Reference in a new issue