xamarin/Xamarin.Forms

[Bug] DynamicResource not updating when reordering ResourceDictionary in App.xaml

オープン

#6,795 opened on 2019/07/05

 (3 件のコメント) (0 件のリアクション) (1 人の担当者)C# (1,926 件のフォーク)batch import
e/3 :clock3:help wantedp/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

  1. Download/Clone the project.
  2. Run on Android.
  3. Click on the button "Open Test Page" to open a page with DynamicResource set.
  4. Click on "Change resource" to change the theme to dark.
  5. 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.

コントリビューターガイド