[Bug] DynamicResource not updating when reordering ResourceDictionary in App.xaml
#6,795 opened on Jul 5, 2019
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Description
My app supports Light and Dark themes. I implemented the option to change the theme by having two resource dictionaries in separated files, like so:
- Light.xaml
- Dark.xaml
When the user changes the theme to Light, I simply move the Light ResourceDictionary to the last position.
The problem is that this only works for pages opened afterwards. It does not update the DynamicResources from pages already opened.
Steps to Reproduce
- Download/Clone the project.
- Run on Android.
- Click on the button "Open Test Page" to open a page with
DynamicResourceset. - Click on "Change resource" to change the theme to dark.
- Notice that the MainPage still has light theme, but opening the test page results in a dark theme.
Expected Behavior
DynamicResource should be updated when the resource dictionary changes. Even for pages already open and loaded, like what happens with WPF.
Actual Behavior
DynamicResources are not updated, they act like StaticResources.
Basic Information
- Version with issue: 4.0.0.425677
- Last known good version: n/a
- IDE: Visual Studio for Windows.
- Platform Target Frameworks:
- iOS: Latest.
- Android: Android Pie, 28.
- UWP: Not tested.
- Android Support Library Version: 28
- Nuget Packages: See project.
- Affected Devices: Nokia 6.1 plus.
Reproduction Link
https://github.com/NickeManarin/Xamarin.Demos
(I'm using the same project to showcase bugs for other projects too, so ignore the first two buttons)
Edit:
It also happens in iOS, latest version. But I don't remember if the demo project is set up to run the iOS version of the app or not.