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.

Changing the theme has no effect on some controls (only in release)

See original GitHub issue

Description

When I try to switch themes, the style of the button doesn’t seem to change shell is work normal

` public static void ChangeTheme(string mode) { ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries; mergedDictionaries.Clear(); if (mode == “朱”) { mergedDictionaries.Add(new ScarletTheme()); } else { mergedDictionaries.Add(new VioletTheme());

    }
    //mergedDictionaries.Add(keyValuePairs);
    Preferences.Set("ColorMode", mode);

}

`

Steps to Reproduce

  1. Create Two Theme
  2. click button to changeTheme

Link to public reproduction project repository

https://github.com/ssccinng/PokeSci/tree/master/SVPokeDex

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android11

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
XceedBoucherScommented, May 17, 2023

Hi @BretJohnson, Thanks for the informations. I upgraded to VS 17.6. I now have “7.0.86/7.0.100” with “dotnet workload list”.

Now, clearing the Application.Current.Resources.MergedDictionaries to set a new resourceDictionary works as expected : my new styles are applied. On the other hand, simply doing a Application.Current.Resources.MergedDictionaries.Clear() do not set the style back to original value.

Here’s my sample: in XAML: <Button Text=“Clear” Clicked=“Button_Clicked_1” />

  <Button Text="Set Red"
          Clicked="Button_Clicked_2"/>

  <Button Text="Set Blue"
          Clicked="Button_Clicked_3" />`

in code-behind: private void Button_Clicked_1( object sender, EventArgs e ) { Application.Current.Resources.MergedDictionaries.Clear(); }

private void Button_Clicked_2( object sender, EventArgs e ) { Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add( new Dictionary1() ); }

private void Button_Clicked_3( object sender, EventArgs e ) { Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add( new Dictionary2() ); }

ResourceDictionaries are attached to this conversation.

clicking to activate callback “Button_Clicked_1” do not reset Button Background to default value. ResourceDictionary.txt

0reactions
BretJohnsoncommented, May 17, 2023

Hi, how can I test this service release ? I downloaded the maui-7.0.86 source code. What is the next step to create a new sample with that version of MAUI ? Thanks

@XceedBoucherS - MAUI 7.0.86 is included in Visual Studio 17.6, released yesterday. See https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-6-now-available/#comment-28752. If you upgrade to VS 17.6, you should have it. You can confirm by doing a dotnet workload list and looking for 7.0.86/7.0.100 in the manifest versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I changed theme but cannot see new theme, it is still on old ...
Hi,. I have changed Theme from Twenty Nineteen to Public Blog theme. When I am in the admin mode, i can see on...
Read more >
Dark theme not working · Issue #1746 · xournalpp ...
Hello, i just installed the latest release of Xournal++ (1.0.17) on my ... No, the dark theme only affects the color of the...
Read more >
Trying to reload view controller to update the current theme
The way to use is really simple, to change all UILabel background color ... will toggle between this two (I only changed a...
Read more >
10 Common WordPress Theme Issues & How To Fix Them
Common WordPress errors with solutions. We address some of the most common WordPress theme issues and provide easy solutions to fix them.
Read more >
Respond to system theme changes - .NET MAUI
NET MAUI app can respond to operating system theme changes by using the AppThemeBinding markup extension, and the SetAppThemeColor and ...
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