|
@@ -569,6 +569,46 @@ public class StyledElementTests_Theming
|
|
|
Assert.Equal(Brushes.Green, border.Background);
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void TemplatedParent_Theme_Change_Applies_Recursively_To_VisualChildren()
|
|
|
+ {
|
|
|
+ var theme = CreateDerivedTheme();
|
|
|
+ var target = CreateTarget();
|
|
|
+
|
|
|
+ Assert.Null(target.Theme);
|
|
|
+ Assert.Null(target.Template);
|
|
|
+
|
|
|
+ var root = CreateRoot(target, theme.BasedOn);
|
|
|
+
|
|
|
+ Assert.NotNull(target.Theme);
|
|
|
+ Assert.NotNull(target.Template);
|
|
|
+
|
|
|
+ root.Styles.Add(new Style(x => x.OfType<ThemedControl>().Class("foo"))
|
|
|
+ {
|
|
|
+ Setters = { new Setter(StyledElement.ThemeProperty, theme) }
|
|
|
+ });
|
|
|
+
|
|
|
+ root.LayoutManager.ExecuteLayoutPass();
|
|
|
+
|
|
|
+ var border = Assert.IsType<Border>(target.VisualChild);
|
|
|
+ var inner = Assert.IsType<Border>(border.Child);
|
|
|
+
|
|
|
+ Assert.Equal(Brushes.Red, border.Background);
|
|
|
+ Assert.Equal(Brushes.Red, inner.Background);
|
|
|
+
|
|
|
+ Assert.Equal(null, inner.BorderBrush);
|
|
|
+ Assert.Equal(null, inner.BorderBrush);
|
|
|
+
|
|
|
+ target.Classes.Add("foo");
|
|
|
+ root.LayoutManager.ExecuteLayoutPass();
|
|
|
+
|
|
|
+ Assert.Equal(Brushes.Green, border.Background);
|
|
|
+ Assert.Equal(Brushes.Green, inner.Background);
|
|
|
+
|
|
|
+ Assert.Equal(Brushes.Cyan, inner.BorderBrush);
|
|
|
+ Assert.Equal(Brushes.Cyan, inner.BorderBrush);
|
|
|
+ }
|
|
|
+
|
|
|
private static ThemedControl CreateTarget()
|
|
|
{
|
|
|
return new ThemedControl();
|
|
@@ -595,7 +635,8 @@ public class StyledElementTests_Theming
|
|
|
|
|
|
private static ControlTheme CreateTheme(string tag = "theme")
|
|
|
{
|
|
|
- var template = new FuncControlTemplate<ThemedControl>((o, n) => new Border());
|
|
|
+ var template = new FuncControlTemplate<ThemedControl>(
|
|
|
+ (o, n) => new Border() { Child = new Border() });
|
|
|
|
|
|
return new ControlTheme
|
|
|
{
|