Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to open the app in full screen without a taskbar with WinUI 3 #6596

Closed
1 of 2 tasks
raushanalert opened this issue Jan 13, 2022 · 16 comments
Closed
1 of 2 tasks
Labels
area-AppWindow needs-triage Issue needs to be triaged by the area owners product-winui3 WinUI 3 issues question team-CompInput Issue for IXP (Composition, Input) team

Comments

@raushanalert
Copy link

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.
App FullScreen Issue

Steps to reproduce the bug

Just Run App default screen showing

Expected behavior

open the app in fullscreen without a taskbar

Screenshots

defaultscreen

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

  • UWP
  • Win32

Device form factor

Desktop

Windows version

May 2021 Update (19043)

Additional context

No response

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jan 13, 2022
@gabbybilka gabbybilka added the product-winui3 WinUI 3 issues label Feb 8, 2022
@StephenLPeters StephenLPeters added area-AppWindow question and removed needs-triage Issue needs to be triaged by the area owners labels Mar 2, 2022
@StephenLPeters
Copy link
Contributor

@codendone @marb2000 @MikeHillberg any of you know the correct way to do this in Winui3?

@FrogsLegs
Copy link

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?

@castorix
Copy link

You can set FullScreen with
AppWindow.SetPresenter and Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen

@FrogsLegs
Copy link

FrogsLegs commented Aug 15, 2022

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:

image

@castorix
Copy link

castorix commented Aug 15, 2022

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)

@wulf11
Copy link

wulf11 commented Aug 19, 2022

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();
            }

@FrogsLegs
Copy link

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.

@ligf
Copy link

ligf commented Aug 23, 2022

您可以使用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;

@FrogsLegs
Copy link

FrogsLegs commented Aug 23, 2022

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?

@FrogsLegs
Copy link

Does anyone have a working sample on Win 11 21H2 that runs TopMost full screen?

@OculiViridi
Copy link

@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).

@LahkLeKey
Copy link

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>

image

@isourabhsingh
Copy link

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

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

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.

@bpulliam bpulliam added the team-Reach Issue for the Reach team label Aug 8, 2023
@bpulliam bpulliam added team-CompInput Issue for IXP (Composition, Input) team and removed team-Reach Issue for the Reach team labels Aug 23, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Aug 23, 2023
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Aug 29, 2023
@duncanmacmichael
Copy link
Member

Closing this issue as it appears to have had multiple solutions presented and has had no activity in 10 months.

@HO-COOH
Copy link

HO-COOH commented May 25, 2024

This issue somehow gets a new way to solve in #9674 😄

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-AppWindow needs-triage Issue needs to be triaged by the area owners product-winui3 WinUI 3 issues question team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests