Added PropertyHelper

This commit is contained in:
ClemensF 2021-01-17 23:39:20 +01:00
parent 67e9989327
commit 068a9ef8a6
11 changed files with 76 additions and 61 deletions

View file

@ -4,7 +4,6 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
namespace MapControl
{
@ -49,24 +48,13 @@ namespace MapControl
{
base.OnApplyTemplate();
var map = MapPanel.GetParentMap(this);
var parentMap = MapPanel.GetParentMap(this);
if (map != null)
if (parentMap != null)
{
if (Background == null)
{
SetBinding(BackgroundProperty, new Binding { Source = map, Path = new PropertyPath(nameof(MapBase.Background)) });
}
if (BorderBrush == null)
{
SetBinding(BorderBrushProperty, new Binding { Source = map, Path = new PropertyPath(nameof(MapBase.Foreground)) });
}
if (Foreground == null)
{
SetBinding(ForegroundProperty, new Binding { Source = map, Path = new PropertyPath(nameof(MapBase.Foreground)) });
}
this.ValidateProperty(BackgroundProperty, parentMap, nameof(MapBase.Background));
this.ValidateProperty(BorderBrushProperty, parentMap, nameof(MapBase.Foreground));
this.ValidateProperty(ForegroundProperty, parentMap, nameof(MapBase.Foreground));
}
}
}