Open asklar opened 3 years ago
This is expected and by design. {StaticResource}
's resource lookup logic only runs once, when the parser processes the markup (in this case, the template for the underlying native XAML control, e.g. Button
). No mechanism exists for forcing the logic to run a second time to reflect changes to the ResourceDictionary hierarchy short of literally recreating the element using the {StaticResource}
.
tagging @MikeHillberg, let's discuss this and the motivation behind this as a feature request :)
FYI @bartekk8
A StaticResource in markup is just like doing an assignment in code; to update it you need to re-execute it. Implicit styles and data binding are dynamic though, maybe we could use those as a mechanism here.
My expectation on how this should work, based on nothing but common sense :D :
Agree that the main problem is the lack of a mechanism for children to be notified of an ancestor's ResourceDictionary changing. Do you have thoughts on how we can use data binding and implicit styles to achieve this? I'm looking at using ResourceDictionary in RNW to implement lightweight styling that can interface or at least be analogous with FURN
My expectation on how this should work, based on nothing but common sense :D
Agreed. The developer expectation is that these should be dynamic. WPF had DynamicResource and that doesn't exist in the StaticResource/ThemeResource system of system XAML and WinUI. It feels like a gap and one we need to resolve in the resource system design eventually.
Internal tracking: http://task.ms/39897009
XAML Version: System XAML Scenario: When doing Hot reload in React Native, some styling needs to change as a response to the user changing app code out from under the app
Running through this code the first time correctly sets the value and it renders. The second time this code runs through, the control does not re-render. Removing the element from the ResourceDictionary does not fix it either