using Avalonia.Controls; using System; #pragma warning disable AVP1001 // The same AvaloniaProperty should not be registered twice namespace MapControl { public static class DependencyPropertyHelper { public static StyledProperty Register( string name, TValue defaultValue = default, Action changed = null, Func coerce = null, bool bindTwoWayByDefault = false) where TOwner : AvaloniaObject { var property = AvaloniaProperty.Register(name, defaultValue, false, bindTwoWayByDefault ? Avalonia.Data.BindingMode.TwoWay : Avalonia.Data.BindingMode.OneWay, null, coerce != null ? ((obj, value) => coerce((TOwner)obj, value)) : null); if (changed != null) { property.Changed.AddClassHandler((o, e) => changed(o, e.OldValue.Value, e.NewValue.Value)); } return property; } public static AttachedProperty RegisterAttached( string name, TValue defaultValue = default, bool inherits = false, Action changed = null) where TOwner : AvaloniaObject { var property = AvaloniaProperty.RegisterAttached(name, defaultValue, inherits); if (changed != null) { property.Changed.AddClassHandler((o, e) => changed(o, e.OldValue.Value, e.NewValue.Value)); } return property; } } }