2021-06-14 21:41:37 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
|
|
|
|
// © 2021 Clemens Fischer
|
2021-01-17 23:39:20 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2021-06-14 21:41:37 +02:00
|
|
|
|
#if WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Data;
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#elif UWP
|
2021-01-17 23:39:20 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2021-06-14 21:41:37 +02:00
|
|
|
|
internal static class BindingHelper
|
2021-01-17 23:39:20 +01:00
|
|
|
|
{
|
|
|
|
|
|
public static Binding GetBinding(this object sourceObject, string sourceProperty)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Binding { Source = sourceObject, Path = new PropertyPath(sourceProperty) };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void ValidateProperty(
|
|
|
|
|
|
this FrameworkElement targetObject, DependencyProperty targetProperty, object sourceObject, string sourceProperty)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (targetObject.GetValue(targetProperty) == null &&
|
|
|
|
|
|
targetObject.GetBindingExpression(targetProperty) == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
targetObject.SetBinding(targetProperty, sourceObject.GetBinding(sourceProperty));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|