File scoped namespaces

This commit is contained in:
ClemensFischer 2026-04-13 17:14:49 +02:00
parent c14377f976
commit 65aba44af6
152 changed files with 11962 additions and 12115 deletions

View file

@ -5,55 +5,54 @@ using Windows.UI.Xaml;
using Microsoft.UI.Xaml;
#endif
namespace MapControl
namespace MapControl;
public static class DependencyPropertyHelper
{
public static class DependencyPropertyHelper
public static DependencyProperty RegisterAttached<TValue>(
string name,
Type ownerType,
TValue defaultValue = default,
Action<FrameworkElement, TValue, TValue> changed = null)
{
public static DependencyProperty RegisterAttached<TValue>(
string name,
Type ownerType,
TValue defaultValue = default,
Action<FrameworkElement, TValue, TValue> changed = null)
{
var metadata = changed == null
? new PropertyMetadata(defaultValue)
: new PropertyMetadata(defaultValue, (o, e) =>
{
if (o is FrameworkElement element)
{
changed(element, (TValue)e.OldValue, (TValue)e.NewValue);
}
});
return DependencyProperty.RegisterAttached(name, typeof(TValue), ownerType, metadata);
}
public static DependencyProperty Register<TOwner, TValue>(
string name,
TValue defaultValue = default,
Action<TOwner, TValue, TValue> changed = null)
where TOwner : DependencyObject
{
var metadata = changed != null
? new PropertyMetadata(defaultValue, (o, e) => changed((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue))
: new PropertyMetadata(defaultValue);
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
}
public static DependencyProperty AddOwner<TOwner, TValue>(
string name,
DependencyProperty source,
Action<TOwner, TValue, TValue> changed = null)
where TOwner : DependencyObject
{
var metadata = new PropertyMetadata(default, (o, e) =>
var metadata = changed == null
? new PropertyMetadata(defaultValue)
: new PropertyMetadata(defaultValue, (o, e) =>
{
o.SetValue(source, e.NewValue);
changed?.Invoke((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue);
if (o is FrameworkElement element)
{
changed(element, (TValue)e.OldValue, (TValue)e.NewValue);
}
});
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
}
return DependencyProperty.RegisterAttached(name, typeof(TValue), ownerType, metadata);
}
public static DependencyProperty Register<TOwner, TValue>(
string name,
TValue defaultValue = default,
Action<TOwner, TValue, TValue> changed = null)
where TOwner : DependencyObject
{
var metadata = changed != null
? new PropertyMetadata(defaultValue, (o, e) => changed((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue))
: new PropertyMetadata(defaultValue);
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
}
public static DependencyProperty AddOwner<TOwner, TValue>(
string name,
DependencyProperty source,
Action<TOwner, TValue, TValue> changed = null)
where TOwner : DependencyObject
{
var metadata = new PropertyMetadata(default, (o, e) =>
{
o.SetValue(source, e.NewValue);
changed?.Invoke((TOwner)o, (TValue)e.OldValue, (TValue)e.NewValue);
});
return DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata);
}
}