簡體   English   中英

winui3中頁面的單個組件可以全屏嗎?

[英]Can a single component of a page be full screen in winui3?

這是canvas實現的視頻stream播放模塊。 winui3如何實現全屏內容?

<Grid>
     <canvas:CanvasControl x:Name="canvas"></canvas:CanvasControl>
</Grid>

你可以這樣做。

<Grid>
    <ToggleButton
        Checked="ToggleButton_CheckChanged"
        Content="Fullscreen"
        Unchecked="ToggleButton_CheckChanged" />
</Grid>
public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();

        IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(this);
        WindowId windowId = Win32Interop.GetWindowIdFromWindow(windowHandle);
        AppWindow = AppWindow.GetFromWindowId(windowId);
    }

    public static AppWindow? AppWindow;

    private void ToggleButton_CheckChanged(object sender, RoutedEventArgs e)
    {
        if (AppWindow is not null &&
            sender is ToggleButton toggleButton)
        {
            AppWindow.SetPresenter(toggleButton.IsChecked is true
                ? AppWindowPresenterKind.FullScreen
                : AppWindowPresenterKind.Default);
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM