Skip to content

Commit

Permalink
Merge pull request #3695 from unoplatform/dev/jela/canvas-autoconvert
Browse files Browse the repository at this point in the history
fix(reg): missing auto-convert in Canvas properties
  • Loading branch information
jeromelaban authored Aug 3, 2020
2 parents 25a507d + 26165c9 commit bac4731
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,26 @@ public void When_SimpleLayout()

Assert.AreEqual(2, CAV.GetChildren().Count());
}

[TestMethod]
public void When_CanvasPropertyConvert()
{
var SUT = new Canvas();

SUT.SetValue(Canvas.LeftProperty, "42");
Assert.AreEqual(42d, SUT.GetValue(Canvas.LeftProperty));

SUT.SetValue(Canvas.LeftProperty, 43);
Assert.AreEqual(43d, SUT.GetValue(Canvas.LeftProperty));

SUT.SetValue(Canvas.LeftProperty, 44f);
Assert.AreEqual(44d, SUT.GetValue(Canvas.LeftProperty));

SUT.SetValue(Canvas.TopProperty, "42");
Assert.AreEqual(42d, SUT.GetValue(Canvas.TopProperty));

SUT.SetValue(Canvas.ZIndexProperty, "42");
Assert.AreEqual(42d, SUT.GetValue(Canvas.ZIndexProperty));
}
}
}
6 changes: 3 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/Canvas/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void SetLeft(DependencyObject obj, double value)
=> SetLeftValue(obj, value);


[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true)]
[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true, Options = FrameworkPropertyMetadataOptions.AutoConvert)]
public static DependencyProperty LeftProperty { get ; } = CreateLeftProperty();

private static void OnLeftChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
Expand All @@ -54,7 +54,7 @@ public static double GetTop(DependencyObject obj)
public static void SetTop(DependencyObject obj, double value)
=> SetTopValue(obj, value);

[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true)]
[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true, Options = FrameworkPropertyMetadataOptions.AutoConvert)]
public static DependencyProperty TopProperty { get ; } = CreateTopProperty();

private static void OnTopChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
Expand All @@ -79,7 +79,7 @@ public static double GetZIndex(DependencyObject obj)
public static void SetZIndex(DependencyObject obj, double value)
=> SetZIndexValue(obj, value);

[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true)]
[GeneratedDependencyProperty(DefaultValue = 0.0d, AttachedBackingFieldOwner = typeof(UIElement), Attached = true, Options = FrameworkPropertyMetadataOptions.AutoConvert)]
public static DependencyProperty ZIndexProperty { get ; } = CreateZIndexProperty();

private static void OnZIndexChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
Expand Down

0 comments on commit bac4731

Please sign in to comment.