共用方式為


ApplicationView.TryEnterFullScreenMode 方法

定義

嘗試以全螢幕模式放置應用程式。

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

傳回

Boolean

bool

如果應用程式處於全螢幕模式,則為true;否則為false

範例

此範例示範如何切換全螢幕模式,並設定 PreferredLaunchWindowingMode 屬性。

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

備註

若要在使用者重新開機應用程式時保留全螢幕模式,如果呼叫 TryEnterFullScreenMode 傳回true,請將PreferredLaunchWindowingMode設定為FullScreen。 當您呼叫 ExitFullScreenMode時,應該將 PreferredLaunchWindowingMode 設定回 AutoPreferredLaunchViewSize

當檢視進入或結束全螢幕模式時,系統會引發 CoreWindow.SizeChanged 事件。 這會以 Window.SizeChanged 事件的形式向 XAML 應用程式公開,並將 HTML 應用程式公開為 window.resize 事件。

適用於

另請參閱