mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
DependencyPropertyHelper
This commit is contained in:
parent
bc12b388de
commit
b7afd27c91
7 changed files with 21 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue