diff --git a/src/Avalonia.Base/StyledElement.cs b/src/Avalonia.Base/StyledElement.cs index b98e378338..42a930c846 100644 --- a/src/Avalonia.Base/StyledElement.cs +++ b/src/Avalonia.Base/StyledElement.cs @@ -304,6 +304,8 @@ namespace Avalonia /// protected virtual Type StyleKeyOverride => GetType(); + protected virtual ControlTheme? ControlThemeOverride => null; + /// /// Gets a value indicating whether the element is attached to a rooted logical tree. /// @@ -688,7 +690,7 @@ namespace Avalonia if (this.TryFindResource(key, out var value) && value is ControlTheme t) _implicitTheme = t; else - _implicitTheme = s_invalidTheme; + _implicitTheme = ControlThemeOverride ?? s_invalidTheme; } if (_implicitTheme != s_invalidTheme)