.NET Maui Min Max Hide Not Showing

Fritz Switzer 281 Reputation points
2024-10-15T15:17:54.7966667+00:00

I'm not seeing my Min, Max and Hide buttons when my screen is maxed. I have set the following

window.ExtendsContentIntoTitleBar = true;

Here is the code I'm using .

   builder.ConfigureLifecycleEvents(events =>
         {
#if WINDOWS
             events.AddWindows(w =>
             {
                 w.OnWindowCreated(window =>
                 {
                     window.ExtendsContentIntoTitleBar = true; //If you need to completely hide the minimized maximized close button, you need to set this value to false.
                     IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
                     WindowId myWndId = Win32Interop.GetWindowIdFromWindow(hWnd);
                     var _appWindow = AppWindow.GetFromWindowId(myWndId);
                     _appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
                 });
             });
#endif
         });
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,542 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    2 deleted comments

    Comments have been turned off. Learn more

  2. Rob Caplan - MSFT 5,452 Reputation points Microsoft Employee
    2024-10-17T20:27:42.9066667+00:00

    FullScreen and Maximized are different states. You want your app to show maximized, which includes the title bar and its widgets, but your code is setting it to full screen, which doesn't show the title bar and its widgets.

    To maximize the window when it's created (as in your code snippet) change this line:

    _appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
    

    To

    // Overlapped is default state
    (_appWindow.Presenter as OverlappedPresenter)?.Maximize();
    

    Pulling that out into a function that can be called elsewhere (assumption: app has only one Window and is currently Overlapped):

    #if WINDOWS
            public void MaximizeWindow()
            {
                var platformView = (MauiWinUIWindow)Application.Current.Windows[0].Handler.PlatformView;
                Microsoft.UI.Windowing.AppWindow? _appWindow = platformView.AppWindow;
                (_appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter)?.Maximize();
            }
    #endif
    

    For more on the difference between FullScreen and Maximized, see the FullScreenPresenter class documentation

    Remarks Full-screen mode is not the same as maximized. When an app is in full-screen mode, it takes up the entirety of the screen. System elements, like title bars, status bars, or the taskbar, are hidden by default. The user can swipe from the bottom to invoke the taskbar, from the left to invoke Task View, from the right to invoke Action Center, and from the top to invoke the title bar.

    When the user switches away from the app to use another app, the full-screen nature of the app is preserved. When the user switches to the app again, it is full-screen.

    0 comments No comments

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.