Browse Source
We should change to the behavior of other XAML frameworks where non-registered `AvaloniaProperty`s can be set on `AvaloniaObject`s via code.pull/1499/head
7 changed files with 156 additions and 12 deletions
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
|||
{ |
|||
public class AttachedPropertyOwner |
|||
{ |
|||
public static readonly AttachedProperty<double> DoubleProperty = |
|||
AvaloniaProperty.RegisterAttached<AttachedPropertyOwner, Control, double>("Double"); |
|||
|
|||
public static double GetDouble(Control control) => control.GetValue(DoubleProperty); |
|||
public static void SetDouble(Control control, double value) => control.SetValue(DoubleProperty, value); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
|||
{ |
|||
public class TestControl : Control |
|||
{ |
|||
public static readonly StyledProperty<double> DoubleProperty = |
|||
AttachedPropertyOwner.DoubleProperty.AddOwner<TestControl>(); |
|||
|
|||
public double Double |
|||
{ |
|||
get => GetValue(DoubleProperty); |
|||
set => SetValue(DoubleProperty, value); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue