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.

Mica BackDropMaterial not updating when RequestedTheme changes

See original GitHub issue

Describe the bug The Mica material is not toggling between light and dark theme when RequestedTheme of the Page to which it is applied changes.

Steps to reproduce the bug

  1. Apply Mica to Page (muxc:BackdropMaterial.ApplyToRootOrPageBackground="True")
  2. Change the RequestedTheme Property of Page from Light to Dark

Expected behavior Background changes according to the theme

Screenshots

Version Info

NuGet package version: 2.7.0-prerelease.210827001

Windows app type:

UWP Win32
Yes
Windows version Saw the problem?
Insider Build (22454.1000) Yes
May 2021 Update (19043)
October 2020 Update (19042)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
eugenegffcommented, Sep 16, 2021

I had similar issue when I set muxc:BackdropMaterial.ApplyToRootOrPageBackground=“True” for control that then became Window.Content. The problem was that Mica infrastructure subscribed to the Window.Content.ActualThemeChanged event for soon-to-be-replaced Window.Content, and then lost the ability to feel theme changes.

Either do not change Window.Content, or set muxc:BackdropMaterial.ApplyToRootOrPageBackground=“True” in code after completing such change.

1reaction
jevansakscommented, Sep 17, 2021

@eugenegff is likely correct. Unfortunately we don’t have a way to do RequestedTheme for a XamlRoot so you set it on the content but then if the content changes or if you set it on a child of the thing that is the root, we don’t know about it.

So you need to set it on Window.Current.Content.RequestedTheme and then don’t change Window.Current.Content.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mica Backdrop effects not working properly on Windows 11 ...
I was checking out the WPF UI and found that the Mica and Acrylic backdrop are not correctly picking up the light or...
Read more >
Mica material not showing up on secondary window
If I click on show second window, It pops up, but the background is in my system-accent-color, not the Mica material.
Read more >
Application.RequestedTheme Property (Windows.UI.Xaml)
You can change specific theme values at run-time after Application.RequestedTheme is applied, if you use the FrameworkElement.RequestedTheme property and sets ...
Read more >
WinUI 3 | XAML Brewer, by Diederik Krols
Mica. The app uses Mica material as its background. When you look at the overly complex way of applying it to your WinUI...
Read more >
Welcome to HandyControl
In HandyControl, almost all native controls have a base style that is implemented by default (that is, when a style is defined, the...
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