Closed LilithSilver closed 4 months ago
I think a simpler fix would be to set RequestedThemeVariant="Light"
on the <Application>
element, and leave the rest of the code as is
I think a simpler fix would be to set
RequestedThemeVariant="Light"
on the<Application>
element, and leave the rest of the code as is
I'd push back against this -- the current approach is actually incorrect, which is the source of this bug. Read this documentation; since we always apply the theme manually, we should be using MaterialThemeBase
instead of MaterialTheme
.
However, MaterialThemeBase
seems to not be working with DialogHost (or something) due to a missing brush at startup. There's a hack fix by overriding the missing brush before the theme is applied, but that's a more complex fix than this one. This lets us just use MaterialTheme.
Ok fair enough. I'm just wary of setting all color brushes by hand like that, for two reasons:
MaterialSecondaryDarkBrush
) are automatically derived from primary/secondary colors by way of adjusting HSL. Correct me if I'm wrong, I haven't checked how it works since ~2017.It looks like the doc you linked doesn't necessarily specify why the current approach is incorrect though, at least I don't see where it does that.
Those points are good ones -- I played around with it a bit more and got MaterialThemeBase
to work with an initial override that later gets set by the theme for the missing brush. (Before I was doing it via code, and it was ugly, but this axaml version looks OK to me).
Let me know what you think.
By the way, the part in the doc that specifies MaterialThemeBase:
NOTE: If you always set theme from code use MaterialThemeBase in your Application.Styles. Because MaterialTheme will create an additional overhead to apply the original styles (written in xaml), which you will override anyway.
Looks good. Can you also please explain why RequestedThemeVariant="Light"
doesn't work, regardless of MaterialTheme
/MaterialThemeBase
approach? My understanding is that it would hard-code the theme so even if the OS-wide requested theme changes, it won't affect the app.
Looks good. Can you also please explain why RequestedThemeVariant="Light" doesn't work, regardless of MaterialTheme/MaterialThemeBase approach? My understanding is that it would hard-code the theme so even if the OS-wide requested theme changes, it won't affect the app.
It does work -- I'll make that change as well. As long as we're correctly using MaterialThemeBase I've got no issues with it.
Thanks!
Closes #296 by forcing light mode on via the theme, and specifying theme colors in
Application.Resources
instead of by manually building a theme.