xamarin-docs icon indicating copy to clipboard operation
xamarin-docs copied to clipboard

Setting a default theme in App.xaml can cause issues on new pages

Open juliandc1969 opened this issue 2 years ago • 0 comments

If, as suggested a 'default theme' is defined in App.xaml, any new pages created will use this 'theme' and not the current theme that has been 'merged'. for example. a simple 2 page app MainPage - containing a page link to SettingsPage SettingsPage - contains a switch that toggles between dark and light themes and a 'back button'

if you: Navigate to Settings page. Toggle the theme from light (the default theme in App.xaml) to dark using the 'merge method' shown - observe the page correctly change theme. Navigate back to MainPage - observe theme is correct. Navigate to the SettingsPage once again - observe the theme has reverted to 'Light' without reaching any code that merges the light theme into the resource dictionary.

To Fix: Remove the default theme from App.xaml In App.xaml.cs App constuctor: Merge in the default theme OR Determine the previously saved theme and merge that.

It may be worth noting this effect on the page so others aren't caught by it.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

juliandc1969 avatar Sep 14 '21 15:09 juliandc1969