Share via


ApplicationView.TryEnterFullScreenMode Method

Definition

Attempts to place the app in full-screen mode.

public:
 virtual bool TryEnterFullScreenMode() = TryEnterFullScreenMode;
bool TryEnterFullScreenMode();
public bool TryEnterFullScreenMode();
function tryEnterFullScreenMode()
Public Function TryEnterFullScreenMode () As Boolean

Returns

Boolean

bool

true if the app is placed in full-screen mode; otherwise, false.

Examples

This example shows how to toggle full-screen mode and set the PreferredLaunchWindowingMode property.

<Button x:Name="ToggleFullScreenModeButton" Content="Toggle full screen" 
        Click="ToggleFullScreenModeButton_Click"/>
private void ToggleFullScreenModeButton_Click(object sender, RoutedEventArgs e)
{
    var view = ApplicationView.GetForCurrentView();
    if (view.IsFullScreenMode)
    {
        view.ExitFullScreenMode();
        ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
        // The SizeChanged event will be raised when the exit from full-screen mode is complete.
    }
    else
    {
        if (view.TryEnterFullScreenMode())
        {
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
            // The SizeChanged event will be raised when the entry to full-screen mode is complete.
        }
    }
}

Remarks

To preserve full screen mode when a user restarts the app, set PreferredLaunchWindowingMode to FullScreen if the call to TryEnterFullScreenMode returns true. When you call ExitFullScreenMode, you should set PreferredLaunchWindowingMode back to Auto or PreferredLaunchViewSize.

The system raises the CoreWindow.SizeChanged event when the view enters or exits full screen mode. This is exposed to XAML apps as the Window.SizeChanged event and to HTML apps as the window.resize event.

Applies to

See also