WinUI 3 Fullscreen

Little Athan 46 Reputation points
2022-08-24T19:15:50.59+00:00

I want to make an app for a kiosk. UWP was my previous choice, but now I want to use the WINUI 3 Gallery. The reason is to modernize my app. I can live without the kiosk mode that the WINUI 3 doesn't support, but I can't do without proper Fullscreen.

I believe I tried everything. For now I have my app as maximized with the PInvoke.

Any tips on how I have my app in full screen or if somehow I can use the WPF Xaml WindowStyle="None" WindowState="Maximized"?

The App is on Win10 and 11

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
785 questions
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 17,841 Reputation points Microsoft Vendor
    2022-08-25T08:36:23.597+00:00

    Hello @Little Athan ,
    Welcome to Microsoft Q&A!

    Full screen can be used in winui3.
    The usage of full screen is mentioned in the document Migrate from UWP to the Windows App SDK.

    Here is an example of button event triggering full screen,(It is recommended to use the latest Windows App SDK 1.1)

    using Microsoft.UI;  
    using Microsoft.UI.Windowing;  
    using Microsoft.UI.Xaml;  
    using Microsoft.UI.Xaml.Controls;  
    using Microsoft.UI.Xaml.Controls.Primitives;  
    using Microsoft.UI.Xaml.Data;  
    using Microsoft.UI.Xaml.Input;  
    using Microsoft.UI.Xaml.Media;  
    using Microsoft.UI.Xaml.Navigation;  
    using System;  
    using System.Collections.Generic;  
    using System.IO;  
    using System.Linq;  
    using System.Runtime.InteropServices.WindowsRuntime;  
    using Windows.Foundation;  
    using Windows.Foundation.Collections;  
      
    using WinRT.Interop;  
      
    // To learn more about WinUI, the WinUI project structure,  
    // and more about our project templates, see: http://aka.ms/winui-project-info.  
      
    namespace Winui3FullScreen  
    {  
        /// <summary>  
        /// An empty window that can be used on its own or navigated to within a Frame.  
        /// </summary>  
        public sealed partial class MainWindow : Window  
        {  
            private AppWindow _appWindow;  
            public MainWindow()  
            {  
                this.InitializeComponent();  
                _appWindow = GetAppWindowForCurrentWindow();  
            }  
      
            private void myButton_Click(object sender, RoutedEventArgs e)  
            {  
                myButton.Content = "Clicked";  
                if (_appWindow.Presenter.Kind == AppWindowPresenterKind.FullScreen)  
                {  
                    _appWindow.SetPresenter(AppWindowPresenterKind.Default);  
                    myButton.Content = "Full Screen";  
                }  
                else  
                {  
                    _appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);  
                    myButton.Content = "Exit Full Screen";  
                }  
            }  
      
            private AppWindow GetAppWindowForCurrentWindow()  
            {  
                IntPtr hWnd = WindowNative.GetWindowHandle(this);  
                WindowId myWndId = Win32Interop.GetWindowIdFromWindow(hWnd);  
                return AppWindow.GetFromWindowId(myWndId);  
            }  
        }  
    }  
    

    234788-a45cf97b-e02c-4005-a6df-ed74ddef0a59.gif

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    4 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Castorix31 85,366 Reputation points
    2022-08-24T20:13:50.837+00:00

    You can see the function SetFullScreen in one of the samples I had uploaded in CMediaEngine.cs
    (adapted from MSDN doc, with mainly the line :
    apw.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen);)

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.