Black StatusBar with black font in Windows 10 mobi

2019-02-18 08:50发布

I have a Windows 10 UWP app running on mobile. When I run the app in an emulator, everything works fine. When I run it on a device (Lumia 550), the StatusBar is black with black font and the status indicators are not visible.

enter image description here

Is this some kind of bug?

I know I can force the StatusBar to have white background and black color, but the requirement for the app is to stick with the theme (black StatusBar in dark theme, white in Light theme).

If I create a new empty Windows 10 app and run it on a device, the problem is the same, it is not specific to my app.

5条回答
ら.Afraid
2楼-- · 2019-02-18 09:12

In your reference Manager add Windows Mobile extensions for the UWP

enter image description here

Then in App.XAML.cs on

protected override void OnLaunched(LaunchActivatedEventArgs e)

add

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
statusBar.BackgroundColor = Windows.UI.Colors.Green;
statusBar.BackgroundOpacity = 1;
statusBar.ForegroundColor = Colors.White;
}

If you want to change Title bar on PC version of UWP app, then you could use this

if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
{
    var titleBar = ApplicationView.GetForCurrentView().TitleBar;
    if (titleBar != null)
    {
        titleBar.ButtonBackgroundColor = Colors.DarkBlue;
        titleBar.ButtonForegroundColor = Colors.White;
        titleBar.BackgroundColor = Colors.Blue;
        titleBar.ForegroundColor = Colors.White;
    }
 }
查看更多
狗以群分
3楼-- · 2019-02-18 09:13

If you got the black font on the black background with your Light theme project, simple add this line into OnLaunched method in App.xaml.cs:

rootFrame.Background = new SolidColorBrush(Colors.White);
查看更多
该账号已被封号
4楼-- · 2019-02-18 09:18

Just add RequestedTheme="Dark"in App.xaml

查看更多
别忘想泡老子
5楼-- · 2019-02-18 09:25

Edit
Here's a more proper answer:

In Windows 10 Mobile the statusbar inherits it's background color from the topmost page. The foreground color is inherited from RequestedTheme.

This means that if you set the background color of your page to black and your RequestedTheme to Light (which gives a white foreground color), the text will be black on black.

Original post
Have you read this?: https://stenobot.wordpress.com/2015/07/08/uwp-app-development-styling-the-mobile-status-bar/

It might help you.

查看更多
趁早两清
6楼-- · 2019-02-18 09:31

I have struggled with this a bit.

A strange thing is that when I start my app, the theme (Application.RequestedTheme) is always Light, ignoring the setting on the phone. Even when I try to set it to Dark in the constructor, it immediately reverts to Light. This could explain the black foreground color.

I also experience the inconsistency between simulator and device. To take care of that, I (as suggested in other answer) set the background color of the page (not the root Grid):

<Page
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    ... >

</Page>

With this, the status bar at least appear readable.

查看更多
登录 后发表回答