Default ForegroundColor of StatusBar depending on Theme
I am looking for the default ForegroundColor (or resource key) of the StatusBar in the Light or Dark Theme. I need to set the ForegroundColor manually because it seems to be not updated according to the RequestedTheme .
If I set the RequestedTheme in my app to Light and the SystemTheme is Dark, the StatusBar will be displayed with white ForegroundColor . I expected that the ForegroundColor of the StatusBar depends on the App's RequestedTheme .
The only known way to change the StatusBar colors so far is by doing it in C#. No XAML resources to override unfortunately. You can change the StatusBar colors like so:
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.Black;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Colors.White;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView() has more properties btw.
If you want to be able to change the colors depending on which theme is requested, you could check for the requested theme:
if( Application.Current.RequestedTheme == ApplicationTheme.Light )
{
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.Black;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Colors.White;
}
链接地址: http://www.djcxy.com/p/68022.html
