mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-28 11:24:13 +01:00
Removed BindingHelper
This commit is contained in:
parent
8bb7dc3eb3
commit
3d275cd924
|
|
@ -1,25 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using Avalonia.Data;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
internal static class BindingHelper
|
||||
{
|
||||
public static Binding CreateBinding(this object source, string property)
|
||||
{
|
||||
return new Binding
|
||||
{
|
||||
Source = source,
|
||||
Path = property
|
||||
};
|
||||
}
|
||||
|
||||
public static void SetBinding(this AvaloniaObject target, AvaloniaProperty property, Binding binding)
|
||||
{
|
||||
target.Bind(property, binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Shared\*.cs" />
|
||||
<Compile Remove="..\Shared\BindingHelper.cs" />
|
||||
<Compile Remove="..\Shared\GeoImage.cs" />
|
||||
<Compile Remove="..\Shared\MapItem.cs" />
|
||||
<Compile Remove="..\Shared\MapItemsControl.cs" />
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
internal static class BindingHelper
|
||||
{
|
||||
public static Binding CreateBinding(this FrameworkElement source, string property)
|
||||
{
|
||||
return new Binding
|
||||
{
|
||||
Source = source,
|
||||
Path = new PropertyPath(property)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,13 @@ using System.Globalization;
|
|||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
#elif UWP
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
|
@ -19,12 +21,13 @@ using Windows.UI.Xaml.Shapes;
|
|||
using Windows.Foundation;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
#elif AVALONIA
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Media;
|
||||
using DependencyProperty = Avalonia.AvaloniaProperty;
|
||||
using HorizontalAlignment = Avalonia.Layout.HorizontalAlignment;
|
||||
using VerticalAlignment = Avalonia.Layout.VerticalAlignment;
|
||||
|
|
@ -75,11 +78,22 @@ namespace MapControl
|
|||
{
|
||||
base.SetParentMap(map);
|
||||
|
||||
line.SetBinding(Shape.StrokeProperty, map.CreateBinding(nameof(Map.Foreground)));
|
||||
line.SetBinding(Shape.StrokeThicknessProperty, this.CreateBinding(nameof(StrokeThickness)));
|
||||
#if AVALONIA
|
||||
line.Bind(Shape.StrokeProperty,
|
||||
new Binding { Source = map, Path = nameof(MapBase.Foreground) });
|
||||
|
||||
line.Bind(Shape.StrokeThicknessProperty,
|
||||
new Binding { Source = this, Path = nameof(StrokeThickness) });
|
||||
#else
|
||||
line.SetBinding(Shape.StrokeProperty,
|
||||
new Binding { Source = map, Path = new PropertyPath(nameof(MapBase.Foreground)) });
|
||||
|
||||
line.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(StrokeThickness)) });
|
||||
#endif
|
||||
#if UWP || WINUI
|
||||
label.SetBinding(TextBlock.ForegroundProperty, map.CreateBinding(nameof(Map.Foreground)));
|
||||
label.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding { Source = map, Path = new PropertyPath(nameof(MapBase.Foreground)) });
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@
|
|||
<Compile Include="..\Shared\AzimuthalProjection.cs">
|
||||
<Link>AzimuthalProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\BindingHelper.cs">
|
||||
<Link>BindingHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\BingMapsTileLayer.cs">
|
||||
<Link>BingMapsTileLayer.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
|
|
@ -61,15 +63,18 @@ namespace MapControl
|
|||
//
|
||||
if (Background == null)
|
||||
{
|
||||
SetBinding(BackgroundProperty, parentMap.CreateBinding(nameof(Background)));
|
||||
SetBinding(BackgroundProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Background)) });
|
||||
}
|
||||
if (Foreground == null)
|
||||
{
|
||||
SetBinding(ForegroundProperty, parentMap.CreateBinding(nameof(Foreground)));
|
||||
SetBinding(ForegroundProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Foreground)) });
|
||||
}
|
||||
if (BorderBrush == null)
|
||||
{
|
||||
SetBinding(BorderBrushProperty, parentMap.CreateBinding(nameof(Foreground)));
|
||||
SetBinding(BorderBrushProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Foreground)) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ using System.Linq;
|
|||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
#endif
|
||||
|
|
@ -63,7 +65,8 @@ namespace MapControl
|
|||
{
|
||||
if (map != null && Foreground == null)
|
||||
{
|
||||
SetBinding(ForegroundProperty, map.CreateBinding(nameof(Foreground)));
|
||||
SetBinding(ForegroundProperty,
|
||||
new Binding { Source = map, Path = new PropertyPath(nameof(Foreground)) });
|
||||
}
|
||||
|
||||
base.SetParentMap(map);
|
||||
|
|
@ -75,8 +78,11 @@ namespace MapControl
|
|||
|
||||
if (Children.Count == 0)
|
||||
{
|
||||
path.SetBinding(Shape.StrokeProperty, this.CreateBinding(nameof(Foreground)));
|
||||
path.SetBinding(Shape.StrokeThicknessProperty, this.CreateBinding(nameof(StrokeThickness)));
|
||||
path.SetBinding(Shape.StrokeProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(Foreground)) });
|
||||
|
||||
path.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(StrokeThickness)) });
|
||||
|
||||
Children.Add(path);
|
||||
}
|
||||
|
|
@ -94,12 +100,17 @@ namespace MapControl
|
|||
else
|
||||
{
|
||||
textBlock = new TextBlock { RenderTransform = new MatrixTransform() };
|
||||
textBlock.SetBinding(TextBlock.FontSizeProperty, this.CreateBinding(nameof(FontSize)));
|
||||
textBlock.SetBinding(TextBlock.ForegroundProperty, this.CreateBinding(nameof(Foreground)));
|
||||
|
||||
textBlock.SetBinding(TextBlock.FontSizeProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(FontSize)) });
|
||||
|
||||
textBlock.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(Foreground)) });
|
||||
|
||||
if (FontFamily != null)
|
||||
{
|
||||
textBlock.SetBinding(TextBlock.FontFamilyProperty, this.CreateBinding(nameof(FontFamily)));
|
||||
textBlock.SetBinding(TextBlock.FontFamilyProperty,
|
||||
new Binding { Source = this, Path = new PropertyPath(nameof(FontFamily)) });
|
||||
}
|
||||
|
||||
Children.Add(textBlock);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ using Windows.System;
|
|||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
#endif
|
||||
|
||||
|
|
@ -53,15 +55,18 @@ namespace MapControl
|
|||
//
|
||||
if (Background == null)
|
||||
{
|
||||
SetBinding(BackgroundProperty, parentMap.CreateBinding(nameof(Background)));
|
||||
SetBinding(BackgroundProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Background)) });
|
||||
}
|
||||
if (Foreground == null)
|
||||
{
|
||||
SetBinding(ForegroundProperty, parentMap.CreateBinding(nameof(Foreground)));
|
||||
SetBinding(ForegroundProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Foreground)) });
|
||||
}
|
||||
if (BorderBrush == null)
|
||||
{
|
||||
SetBinding(BorderBrushProperty, parentMap.CreateBinding(nameof(Foreground)));
|
||||
SetBinding(BorderBrushProperty,
|
||||
new Binding { Source = parentMap, Path = new PropertyPath(nameof(Foreground)) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue