Home > C#, Universal Windows Platform > Full Screen Mode in Windows 10 Universal apps

Full Screen Mode in Windows 10 Universal apps

09/07/2015

Windows 8/8.1 apps on a Windows 10 Desktop are shown in window, as usual. But, in this case, on the title bar appears a button that allows to put the app in full-screen mode, to resemble the old style.

In fact, we can leverage a new API to show our apps in full-screen mode even if we’re using the new Universal Windows Platform. Note that in this case we haven’t a built-in command to enter/exit this mode, so we need to provide it in our apps.

So, for example, we can write something like this:

private async void toggleFullScreenButton_Click(object sender, RoutedEventArgs e)
{
    var view = ApplicationView.GetForCurrentView();
    if (view.IsFullScreenMode)
    {
        view.ExitFullScreenMode();
    }
    else
    {
        var succeeded = view.TryEnterFullScreenMode();
        if (!succeeded)
        {
            var dialog = new MessageDialog("Unable to enter the full-screen mode.");
            await dialog.ShowAsync();
        }
    }
}

First of all, we check if the app is already in full-screen mode (line 4). If so, we call the ExitFullScreenMode method (line 6) to return to the standard windowed mode. Otherwise, we call TryEnterFullScreenMode (line 10) to attempt to place the app in full-screen mode. This method can fail, so we check its return value to determine whether the app is actually placed in full-screen mode.

Note that the full-screen APIs is available also on phones. In this case, a full-screen app has no statusbar and no “soft navigation buttons”.

%d bloggers like this: