|
|
@@ -393,6 +393,38 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void Control_Property_Is_Updated_When_Parent_Is_Changed()
|
|
|
+ {
|
|
|
+ var xaml = @"
|
|
|
+<UserControl xmlns='https://github.com/avaloniaui'
|
|
|
+ xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
|
+ <UserControl.Resources>
|
|
|
+ <SolidColorBrush x:Key='brush'>#ff506070</SolidColorBrush>
|
|
|
+ </UserControl.Resources>
|
|
|
+
|
|
|
+ <Border Name='border' Background='{DynamicResource brush}'/>
|
|
|
+</UserControl>";
|
|
|
+
|
|
|
+ var loader = new AvaloniaXamlLoader();
|
|
|
+ var userControl = (UserControl)loader.Load(xaml);
|
|
|
+ var border = userControl.FindControl<Border>("border");
|
|
|
+
|
|
|
+ DelayedBinding.ApplyBindings(border);
|
|
|
+
|
|
|
+ var brush = (SolidColorBrush)border.Background;
|
|
|
+ Assert.Equal(0xff506070, brush.Color.ToUint32());
|
|
|
+
|
|
|
+ userControl.Content = null;
|
|
|
+
|
|
|
+ Assert.Null(border.Background);
|
|
|
+
|
|
|
+ userControl.Content = border;
|
|
|
+
|
|
|
+ brush = (SolidColorBrush)border.Background;
|
|
|
+ Assert.Equal(0xff506070, brush.Color.ToUint32());
|
|
|
+ }
|
|
|
+
|
|
|
private IDisposable StyledWindow(params (string, string)[] assets)
|
|
|
{
|
|
|
var services = TestServices.StyledWindow.With(
|