From 19703360f7286bf8f5faac1cc9be63209c88b5e1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 30 Jun 2022 14:44:34 +0200 Subject: [PATCH] Apply own control theme before templated parent's. --- src/Avalonia.Base/Styling/Styler.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/Styling/Styler.cs b/src/Avalonia.Base/Styling/Styler.cs index 6ac2e8d372..ad5c1cd102 100644 --- a/src/Avalonia.Base/Styling/Styler.cs +++ b/src/Avalonia.Base/Styling/Styler.cs @@ -8,14 +8,14 @@ namespace Avalonia.Styling { _ = target ?? throw new ArgumentNullException(nameof(target)); - // If the control has a themed templated parent then first apply the styles from - // the templated parent theme. + // Apply the control theme. + target.GetEffectiveTheme()?.TryAttach(target, target); + + // If the control has a themed templated parent then apply the styles from the + // templated parent theme. if (target.TemplatedParent is IStyleable styleableParent) styleableParent.GetEffectiveTheme()?.TryAttach(target, styleableParent); - // Next apply the control theme. - target.GetEffectiveTheme()?.TryAttach(target, target); - // Apply styles from the rest of the tree. if (target is IStyleHost styleHost) ApplyStyles(target, styleHost);