question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating ResourceDictionary in code behind doesn't fire change notification

See original GitHub issue

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

  void SetResources(const xaml::FrameworkElement& fe, const JSValueObject& dict) {
    auto rd = ResourceDictionary();

    for (auto const& entry : dict) {
      const auto& name = entry.first;
      const auto& value = entry.second;
      auto brush = ColorUtils::SolidColorBrushFrom(value);

      rd.Insert(winrt::box_value(winrt::to_hstring(name)), brush);
    }
    fe.Resources(rd);
  }

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
chrisgleincommented, Mar 16, 2021

My expectation on how this should work, based on nothing but common sense 😄

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.

0reactions
asklarcommented, Jun 8, 2022

Internal tracking: http://task.ms/39897009

Read more comments on GitHub >

github_iconTop Results From Across the Web

ResourceDictionary dynamic updating not updating UI in ...
I wish to change the styles (for theming) at runtime. I have the following resource dictionary which I include in my views.
Read more >
ResourceDictionary Class (Windows.UI.Xaml) - UWP
Defines a repository for XAML resources, such as styles, that your app uses. You define the resources in XAML and can then retrieve...
Read more >
Design View Appearing While Editing XAML Resource ...
After updating Visual Studios to 16.11.6 the Design View is now appearing when I open a XAML resource dictionary file that holds data...
Read more >
Static And Dynamic Resources In WPF
Let's go ahead and create a WPF application. Static Resource. It will not change once it's assigned and they are applied at the...
Read more >
Create and manage notification channels
After you create a notification channel, you can't change the notification behaviors. The user has complete control at that point. However, you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found