Added DependencyPropertyHelper.AddOwner

This commit is contained in:
ClemensFischer 2026-02-02 14:52:58 +01:00
parent f78bcb33fa
commit a3d25b5084
12 changed files with 119 additions and 133 deletions

View file

@ -40,5 +40,20 @@ namespace MapControl
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);
}
}
}