From 7d696903da912e60db1206402ffea30f934c87d3 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 26 Jul 2023 11:12:27 +0200 Subject: [PATCH] fix: Ensure ThemeResource bindings are properly updated when style is applied --- src/Uno.UI/UI/Xaml/Style/Style.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Style/Style.cs b/src/Uno.UI/UI/Xaml/Style/Style.cs index b7a91cb5b436..d691f9621d99 100644 --- a/src/Uno.UI/UI/Xaml/Style/Style.cs +++ b/src/Uno.UI/UI/Xaml/Style/Style.cs @@ -73,7 +73,7 @@ internal void ApplyTo(DependencyObject o, DependencyPropertyValuePrecedences pre return; } - var localPrecedenceDisposable = DependencyObjectExtensions.OverrideLocalPrecedence(o, precedence); + IDisposable? localPrecedenceDisposable = DependencyObjectExtensions.OverrideLocalPrecedence(o, precedence); EnsureSetterMap(); @@ -91,15 +91,17 @@ internal void ApplyTo(DependencyObject o, DependencyPropertyValuePrecedences pre } } + localPrecedenceDisposable?.Dispose(); + // Check tree for resource binding values, since some Setters may have set ThemeResource-backed values - (o as IDependencyObjectStoreProvider)!.Store.UpdateResourceBindings(ResourceUpdateReason.StaticResourceLoading); + (o as IDependencyObjectStoreProvider)!.Store.UpdateResourceBindings(ResourceUpdateReason.ResolvedOnLoading); } #if !HAS_EXPENSIVE_TRYFINALLY finally #endif { - ResourceResolver.PopScope(); localPrecedenceDisposable?.Dispose(); + ResourceResolver.PopScope(); } }