mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
MapPanel constructor
This commit is contained in:
parent
fde4eccf12
commit
71e7e29200
|
|
@ -18,14 +18,6 @@
|
||||||
AffectsParentArrange<MapPanel>(LocationProperty, BoundingBoxProperty);
|
AffectsParentArrange<MapPanel>(LocationProperty, BoundingBoxProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapPanel()
|
|
||||||
{
|
|
||||||
if (this is MapBase)
|
|
||||||
{
|
|
||||||
SetValue(ParentMapProperty, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MapBase GetParentMap(Control element)
|
public static MapBase GetParentMap(Control element)
|
||||||
{
|
{
|
||||||
return (MapBase)element.GetValue(ParentMapProperty);
|
return (MapBase)element.GetValue(ParentMapProperty);
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,22 @@ namespace MapControl
|
||||||
},
|
},
|
||||||
true); // inherits
|
true); // inherits
|
||||||
|
|
||||||
|
public MapPanel()
|
||||||
|
{
|
||||||
|
UseLayoutRounding = false;
|
||||||
|
|
||||||
|
if (this is MapBase)
|
||||||
|
{
|
||||||
|
SetValue(ParentMapProperty, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InitMapPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void InitMapPanel();
|
||||||
|
|
||||||
private MapBase parentMap;
|
private MapBase parentMap;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,6 @@ namespace MapControl
|
||||||
|
|
||||||
protected IEnumerable<FrameworkElement> ChildElements => InternalChildren.OfType<FrameworkElement>();
|
protected IEnumerable<FrameworkElement> ChildElements => InternalChildren.OfType<FrameworkElement>();
|
||||||
|
|
||||||
public MapPanel()
|
|
||||||
{
|
|
||||||
if (this is MapBase)
|
|
||||||
{
|
|
||||||
SetValue(ParentMapProperty, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MapBase GetParentMap(FrameworkElement element)
|
public static MapBase GetParentMap(FrameworkElement element)
|
||||||
{
|
{
|
||||||
return (MapBase)element.GetValue(ParentMapProperty);
|
return (MapBase)element.GetValue(ParentMapProperty);
|
||||||
|
|
|
||||||
|
|
@ -25,26 +25,18 @@ namespace MapControl
|
||||||
|
|
||||||
protected IEnumerable<FrameworkElement> ChildElements => Children.OfType<FrameworkElement>();
|
protected IEnumerable<FrameworkElement> ChildElements => Children.OfType<FrameworkElement>();
|
||||||
|
|
||||||
public MapPanel()
|
partial void InitMapPanel()
|
||||||
{
|
{
|
||||||
UseLayoutRounding = false;
|
|
||||||
InitMapElement(this);
|
InitMapElement(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitMapElement(FrameworkElement element)
|
public static void InitMapElement(FrameworkElement element)
|
||||||
{
|
{
|
||||||
if (element is MapBase)
|
// Workaround for missing property value inheritance.
|
||||||
{
|
// Loaded and Unloaded handlers set and clear the ParentMap property value.
|
||||||
element.SetValue(ParentMapProperty, element);
|
//
|
||||||
}
|
element.Loaded += (s, e) => GetParentMap((FrameworkElement)s);
|
||||||
else
|
element.Unloaded += (s, e) => ((FrameworkElement)s).ClearValue(ParentMapProperty);
|
||||||
{
|
|
||||||
// Workaround for missing property value inheritance.
|
|
||||||
// Loaded and Unloaded handlers set and clear the ParentMap property value.
|
|
||||||
//
|
|
||||||
element.Loaded += (s, e) => GetParentMap((FrameworkElement)s);
|
|
||||||
element.Unloaded += (s, e) => ((FrameworkElement)s).ClearValue(ParentMapProperty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapBase GetParentMap(FrameworkElement element)
|
public static MapBase GetParentMap(FrameworkElement element)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue