using Avalonia.Controls; using System; namespace MapControl { [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1001")] public static class DependencyPropertyHelper { public static AvaloniaProperty Register( string name, TValue defaultValue = default, bool bindTwoWayByDefault = false, Action propertyChanged = null) where TOwner : AvaloniaObject { StyledProperty property = AvaloniaProperty.Register(name, defaultValue, false, bindTwoWayByDefault ? Avalonia.Data.BindingMode.TwoWay : Avalonia.Data.BindingMode.OneWay); if (propertyChanged != null) { property.Changed.AddClassHandler( (o, e) => propertyChanged(o, e.OldValue.Value, e.NewValue.Value)); } return property; } public static AvaloniaProperty RegisterAttached( string name, TValue defaultValue = default, bool inherits = false, Action propertyChanged = null) where TOwner : AvaloniaObject { AttachedProperty property = AvaloniaProperty.RegisterAttached(name, defaultValue, inherits); if (propertyChanged != null) { property.Changed.AddClassHandler( (o, e) => propertyChanged(o, e.OldValue.Value, e.NewValue.Value)); } return property; } } }