mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Updated BindingHelper
This commit is contained in:
parent
0714a04a92
commit
928d12876f
7 changed files with 61 additions and 30 deletions
|
|
@ -57,9 +57,14 @@ namespace MapControl
|
|||
|
||||
if (parentMap != null)
|
||||
{
|
||||
this.ValidateProperty(BackgroundProperty, parentMap, nameof(MapBase.Background));
|
||||
this.ValidateProperty(BorderBrushProperty, parentMap, nameof(MapBase.Foreground));
|
||||
this.ValidateProperty(ForegroundProperty, parentMap, nameof(MapBase.Foreground));
|
||||
// If this.Background is not explicitly set, bind it to parentMap.Background
|
||||
this.SetBindingOnUnsetProperty(BackgroundProperty, parentMap, Panel.BackgroundProperty, nameof(Background));
|
||||
|
||||
// If this.Foreground is not explicitly set, bind it to parentMap.Foreground
|
||||
this.SetBindingOnUnsetProperty(ForegroundProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||
|
||||
// If this.BorderBrush is not explicitly set, bind it to parentMap.Foreground
|
||||
this.SetBindingOnUnsetProperty(BorderBrushProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ namespace MapControl
|
|||
if (path == null)
|
||||
{
|
||||
path = new Path { Data = new PathGeometry() };
|
||||
path.SetBinding(Shape.StrokeProperty, this.GetBinding(nameof(Stroke)));
|
||||
path.SetBinding(Shape.StrokeThicknessProperty, this.GetBinding(nameof(StrokeThickness)));
|
||||
path.SetBinding(Shape.StrokeDashArrayProperty, this.GetBinding(nameof(StrokeDashArray)));
|
||||
path.SetBinding(Shape.StrokeDashOffsetProperty, this.GetBinding(nameof(StrokeDashOffset)));
|
||||
path.SetBinding(Shape.StrokeDashCapProperty, this.GetBinding(nameof(StrokeDashCap)));
|
||||
path.SetBinding(Shape.StrokeProperty, this.GetOrCreateBinding(StrokeProperty, nameof(Stroke)));
|
||||
path.SetBinding(Shape.StrokeThicknessProperty, this.GetOrCreateBinding(StrokeThicknessProperty, nameof(StrokeThickness)));
|
||||
path.SetBinding(Shape.StrokeDashArrayProperty, this.GetOrCreateBinding(StrokeDashArrayProperty, nameof(StrokeDashArray)));
|
||||
path.SetBinding(Shape.StrokeDashOffsetProperty, this.GetOrCreateBinding(StrokeDashOffsetProperty, nameof(StrokeDashOffset)));
|
||||
path.SetBinding(Shape.StrokeDashCapProperty, this.GetOrCreateBinding(StrokeDashCapProperty, nameof(StrokeDashCap)));
|
||||
Children.Add(path);
|
||||
}
|
||||
|
||||
|
|
@ -115,15 +115,15 @@ namespace MapControl
|
|||
else
|
||||
{
|
||||
label = new TextBlock { RenderTransform = new MatrixTransform() };
|
||||
label.SetBinding(TextBlock.FontSizeProperty, this.GetBinding(nameof(FontSize)));
|
||||
label.SetBinding(TextBlock.FontStyleProperty, this.GetBinding(nameof(FontStyle)));
|
||||
label.SetBinding(TextBlock.FontStretchProperty, this.GetBinding(nameof(FontStretch)));
|
||||
label.SetBinding(TextBlock.FontWeightProperty, this.GetBinding(nameof(FontWeight)));
|
||||
label.SetBinding(TextBlock.ForegroundProperty, this.GetBinding(nameof(Foreground)));
|
||||
label.SetBinding(TextBlock.FontSizeProperty, this.GetOrCreateBinding(FontSizeProperty, nameof(FontSize)));
|
||||
label.SetBinding(TextBlock.FontStyleProperty, this.GetOrCreateBinding(FontStyleProperty, nameof(FontStyle)));
|
||||
label.SetBinding(TextBlock.FontStretchProperty, this.GetOrCreateBinding(FontStretchProperty, nameof(FontStretch)));
|
||||
label.SetBinding(TextBlock.FontWeightProperty, this.GetOrCreateBinding(FontWeightProperty, nameof(FontWeight)));
|
||||
label.SetBinding(TextBlock.ForegroundProperty, this.GetOrCreateBinding(ForegroundProperty, nameof(Foreground)));
|
||||
|
||||
if (FontFamily != null)
|
||||
{
|
||||
label.SetBinding(TextBlock.FontFamilyProperty, this.GetBinding(nameof(FontFamily)));
|
||||
label.SetBinding(TextBlock.FontFamilyProperty, this.GetOrCreateBinding(FontFamilyProperty, nameof(FontFamily)));
|
||||
}
|
||||
|
||||
Children.Add(label);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,14 @@ namespace MapControl
|
|||
|
||||
if (parentMap != null)
|
||||
{
|
||||
this.ValidateProperty(BackgroundProperty, parentMap, nameof(MapBase.Background));
|
||||
this.ValidateProperty(BorderBrushProperty, parentMap, nameof(MapBase.Foreground));
|
||||
this.ValidateProperty(ForegroundProperty, parentMap, nameof(MapBase.Foreground));
|
||||
// If this.Background is not explicitly set, bind it to parentMap.Background
|
||||
this.SetBindingOnUnsetProperty(BackgroundProperty, parentMap, Panel.BackgroundProperty, nameof(Background));
|
||||
|
||||
// If this.Foreground is not explicitly set, bind it to parentMap.Foreground
|
||||
this.SetBindingOnUnsetProperty(ForegroundProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||
|
||||
// If this.BorderBrush is not explicitly set, bind it to parentMap.Foreground
|
||||
this.SetBindingOnUnsetProperty(BorderBrushProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,11 @@ namespace MapControl
|
|||
{
|
||||
if (map != null)
|
||||
{
|
||||
this.ValidateProperty(ForegroundProperty, map, nameof(MapBase.Foreground));
|
||||
this.ValidateProperty(StrokeProperty, this, nameof(Foreground));
|
||||
// If this.Forground is not explicitly set, bind it to map.Foreground
|
||||
this.SetBindingOnUnsetProperty(ForegroundProperty, map, MapBase.ForegroundProperty, nameof(Foreground));
|
||||
|
||||
// If this.Stroke is not explicitly set, bind it to this.Foreground
|
||||
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
|
||||
}
|
||||
|
||||
base.SetParentMap(map);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue