Windows 10 UWP – Template 10 Mobile Status Bar

Windows-Dev

Template 10 is a set of Visual Studio project templates for Windows 10 XAML / C# apps.

In my previous post I set the app theme to Light and found that the status bar was completely white on Windows 10 Mobile. The status icons were no longer visible.

Before we can make changes to the status bar we first need to add Windows Mobile Extensions for the UWP  to our references:

In the Solution Explorer right click on References and then click Add Reference. In the left pane select Universal Windows and then Extensions from the drop down menu. In the right hand pane select Windows Mobile Extensions for the UWP and click OK.

Now we can customize the status bar by adding the highlighted code to App.xaml.cs.

public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            // TODO: add your long-running task here
            await NavigationService.NavigateAsync(typeof(Views.MainPage));
           
            //Set StatusBar background and foreground colors
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))

            {
                var statusBar = StatusBar.GetForCurrentView();
                if (statusBar != null)
                {
                    statusBar.BackgroundOpacity = 1;
                    statusBar.BackgroundColor = Colors.Orange;
                    statusBar.ForegroundColor = Colors.White;
                }

Next just add the required using statements as prompted by Visual Studio.

As you can see I set the background color to orange and the text to white:

uwp-status-bar

Sources:

View story at Medium.com

https://stenobot.wordpress.com/2015/07/08/uwp-app-development-styling-the-mobile-status-bar/

https://blogs.msdn.microsoft.com/gianlucb/2015/10/08/uwp-windows-10-app-titlebar-and-status-bar-customization/

Windows Phone Dev – Making the Status Bar blend with your App

Windows8-Phone-Logo

I’m working on a WinRT app for Windows Phone 8.1 and I wanted the app to blend in with the Status Bar more.

For this example I have added the highlighted code to my MainPage.xaml.cs:

        public MainPage()
        {
            this.InitializeComponent();

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;

            // Make Status Bar part of the screen

            ApplicationView.GetForCurrentView().
            SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

        }

In my MainPage.xaml I have simply specified a border background around my first stackpanel:

<!-- TitlePanel -->
        <Border Background="#0050EF">
            <StackPanel Grid.Row="0"
                        Margin="30,0,0,28">
                <TextBlock x:Uid="RegionsPageHeader"
                           FontSize="32"
                           Text="index"
                           Margin="0,40,0,-16"
                           Style="{StaticResource TitleTextBlockStyle}"
                           SelectionChanged="TextBlock_SelectionChanged" />
            </StackPanel>
        </Border>

As you can see from the screenshot the Status bar and my textblock now share the same color.

blennd

Sources: http://blogs.msdn.com/b/johnkenn/archive/2014/04/16/hiding-the-status-bar-in-windows-phone-8-1-apps-or-not.aspx