dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.22k stars 1.75k forks source link

Input Views fail to update styling when ResourceDictionary is changed #18466

Open dimassudjito opened 1 year ago

dimassudjito commented 1 year ago

Description

Some Input Views such as Entry, Picker, and DatePicker fail to update styling when ResourceDictionary is updated. The Input Views use DynamicResource to access the ResourceDictionary. The use case is for applying dark and light theme in the apps. Other Views such as Label, Image, Switch, CheckBox can update style as expected.

Demo: See Readme at the public reproduction project repository

Steps to Reproduce

  1. Create a page with Entry, Picker, and DatePicker
  2. Set up multiple themes uisng ResourceDictionary in App.xaml.cs
  3. Set up mechanism to switch themes on runtime (e.g., using a button)
  4. Add styles to Entry, Picker, and DatePicker using DynamicResource
  5. Switch theme on runtime

Expected outcome: Entry, Picker, and DatePicker switch styling according to the selected theme Actual outcome: Entry, Picker, and DatePicker do not update styling

Link to public reproduction project repository

https://github.com/dimassudjito/LightThemeBug

Version with bug

7.0.92

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Pixel 5 - API 33 (Android 13.0)

Did you find any workaround?

No

Relevant log output

No response

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.8.0 Preview 5.0(8.0.0-rc.2.9373). Repro on Windows 11 and Android 14.0-API34 with below Project: LightThemeBug.zip image

borrmann commented 1 year ago

This also (sometimes) happens on other views such as the Stroke of Borders, labels, and Icons, when those items are on pages that aren't currently open and are not transient, but singletons!

So let's say you change the theme in your settings somewhere and go back to your main page that is registered as a singleton, it might not be updated everywhere.