microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
Is there a way to open the app in full screen without a taskbar with WinUI 3
Describe the bug
any solution to open the app in full screen without a taskbar. (for now we are setting taskbar settings manually (hide))disable / hide window buttons ( minimize , maximize , close buttons).
I have tried to open the app in fullscreen by ApplicationViewWindowingMode.FullScreen but this code is not supported by the application.
Steps to reproduce the bug
Just Run App default screen showing
Expected behavior
open the app in fullscreen without a taskbar
Screenshots

NuGet package version
WinUI 3 - Windows App SDK 1.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
- [X] UWP
- [ ] Win32
Device form factor
Desktop
Windows version
May 2021 Update (19043)
Additional context
No response
@codendone @marb2000 @MikeHillberg any of you know the correct way to do this in Winui3?
With the release of MAUI and now Visual Studio 17.3.0 I still see this behaviour. Is there any update on why this doesn't work or if there is a correct way to approach this with WinUI3?
You can set FullScreen with AppWindow.SetPresenter and Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen
You can set FullScreen with AppWindow.SetPresenter and Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen
Thanks, that does almost work! ....
`var currentWindow = Application.Windows[0].Handler.PlatformView;
IntPtr _windowHandle = WindowNative.GetWindowHandle(currentWindow);
var windowId = Win32Interop.GetWindowIdFromWindow(_windowHandle);
AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);`
The Window bar is weirdly half cut off though:

The Window bar is weirdly half cut off though:
I cannot reproduce this on my configuration (Windows App SDK 1.1.0, Windows 10 21H1) (I can only get this small caption with SetBorderAndTitleBar and not FullScreen)
The Window bar is weirdly half cut off though:
Had the same issue, but the following solution works for me:
var mauiWindow = handler.VirtualView;
var nativeWindow = handler.PlatformView;
nativeWindow.Activate();
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
if(appWindow.Presenter is OverlappedPresenter p)
{
p.Maximize();
}
The Window bar is weirdly half cut off though:
I cannot reproduce this on my configuration (Windows App SDK 1.1.0, Windows 10 21H1) (I can only get this small caption with SetBorderAndTitleBar and not FullScreen)
I've created a sample repo here. Can you please test this on your machine and compare the results. I'm running Win 11 21H2.
您可以使用AppWindow.SetPresenter_和_Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen_设置 FullScreen_
谢谢,这几乎可以工作!……
`var currentWindow = Application.Windows[0].Handler.PlatformView; IntPtr _windowHandle = WindowNative.GetWindowHandle(currentWindow); var windowId = Win32Interop.GetWindowIdFromWindow(_windowHandle); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);`窗口栏奇怪地被截断了一半:
you need to hide the titlebar var nativeWindow = handler.PlatformView; var winuiWindow = nativeWindow as Microsoft.UI.Xaml.Window; winuiWindow.ExtendsContentIntoTitleBar = false;
you need to hide the titlebar var nativeWindow = handler.PlatformView; var winuiWindow = nativeWindow as Microsoft.UI.Xaml.Window; winuiWindow.ExtendsContentIntoTitleBar = false;
Yes I have done that in the sample here. Still the TitleBar is half visible on Win 11 21H2. Can you see different behaviour when running the sample?
Does anyone have a working sample on Win 11 21H2 that runs TopMost full screen?
@FrogsLegs Taking the code from WindowingInterop.cs class in WindowsAppSDK Samples repo let my app works in fullscreen mode (directly at startup, no button to enter/exit fullsreen mode).
net7.0rc-1 (Only tested with MAUI)
Windows
MauiProgram.cs
#if WINDOWS
// using Microsoft.Maui.LifecycleEvents;
// #if WINDOWS
// using Microsoft.UI;
// using Microsoft.UI.Windowing;
// using Windows.Graphics;
// #endif
builder.ConfigureLifecycleEvents(events =>
{
events.AddWindows(windowsLifecycleBuilder =>
{
windowsLifecycleBuilder.OnWindowCreated(window =>
{
window.ExtendsContentIntoTitleBar = false;
var handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
var id = Win32Interop.GetWindowIdFromWindow(handle);
var appWindow = AppWindow.GetFromWindowId(id);
switch (appWindow.Presenter)
{
case OverlappedPresenter overlappedPresenter:
overlappedPresenter.SetBorderAndTitleBar(false, false);
overlappedPresenter.Maximize();
break;
}
});
});
});
#endif
Android
Platforms/Android/MainActivity.cs
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Platform.Init(this, savedInstanceState);
this.Window?.AddFlags(WindowManagerFlags.Fullscreen);
}
}
(Edit MainPage.xml if you are still not full screen in windows)
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:YourApp"
x:Class="YourApp.MainPage"
Title=""
NavigationPage.HasNavigationBar="False">
<BlazorWebView HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type local:Main}" />
</BlazorWebView.RootComponents>
</BlazorWebView>
</ContentPage>

For WinUI 3 App you can use this code
App.MainWindow.ExtendsContentIntoTitleBar = true; Microsoft.UI.Windowing.AppWindow _appWindow; _appWindow = GetAppWindowForCurrentWindow(); _appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
private Microsoft.UI.Windowing.AppWindow GetAppWindowForCurrentWindow() { IntPtr hWnd = WindowNative.GetWindowHandle(App.MainWindow); WindowId myWndId = Win32Interop.GetWindowIdFromWindow(hWnd); return Microsoft.UI.Windowing.AppWindow.GetFromWindowId(myWndId); }
This will help you
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Closing this issue as it appears to have had multiple solutions presented and has had no activity in 10 months.
This issue somehow gets a new way to solve in #9674 😄