Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move and minimize Maui windows application programmatically

I have a maui app with blazor and I'm creating a custom titlebar.

I about to close the maui app, using on blazor Application.Current.Quit();

Now how can i minimize and move maui app

My code blazor

private void MoveWindow()
{
    
}

private void MinimizeWindow()
{
        
}


private void CloseWindow() {
    Application.Current.Quit();
}
like image 258
Pedro alaha Avatar asked Jan 31 '26 05:01

Pedro alaha


1 Answers

Maui already has a function to minimize the application.

Use the following in your blazor:

private void MinimizeWindow()
{
#if WINDOWS
    var Window = App.Current.Windows.First();
    var nativeWindow = Window.Handler.PlatformView;
    IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
    WindowId WindowId = Win32Interop.GetWindowIdFromWindow(windowHandle);
    AppWindow appWindow = AppWindow.GetFromWindowId(WindowId);

    var p = appWindow.Presenter as OverlappedPresenter;

    p.Minimize();
#endif
}
like image 189
Megasantos Avatar answered Feb 01 '26 18:02

Megasantos