Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 3.29 KB

applicationview_preferredlaunchwindowingmode.md

File metadata and controls

62 lines (47 loc) · 3.29 KB
-api-id -api-type
P:Windows.UI.ViewManagement.ApplicationView.PreferredLaunchWindowingMode
winrt property

Windows.UI.ViewManagement.ApplicationView.PreferredLaunchWindowingMode

-description

Gets or sets a value that indicates the windowing mode the app launches with.

-property-value

An enumeration value that indicates the windowing mode of the app.

-remarks

By default, PreferredLaunchWindowingMode is set to Auto. In this mode, the size and position of your app window on startup is managed automatically by Windows.

You can set PreferredLaunchWindowingMode to override the automatic behavior with one of these values.

For the very first launch of an app the PreferredLaunchWindowingMode will always be Auto and the ApplicationView.PreferredLaunchViewSize will be determined by system policies. The API applies to the next launch of the app.

You typically set this property when the user sets their preference via an in-app option, or when you call TryEnterFullScreenMode and ExitFullScreenMode. You can set this property during app startup (before the call to CoreWindow.Activate) to specify a first launch behavior. However, you shouldn't set it during every launch as this can cause your app to do extra sizing and positioning work during startup.

-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.
        }
    }
}

-see-also

IsFullScreenMode, TryEnterFullScreenMode, ExitFullScreenMode, Full screen mode sample, Window resizing sample