I am new to MAUI, and I am trying to port my WPF application so that it runs on Mac Catalyst, and I am blocked trying to port the code that programmatically minimize/restore the current window.
In WPF, it is easy, it is just this.WindowState = WindowState.Minimized
.
I understand that MAUI needs to work on all platform, and minimizing might not make sense for iOS or Android. As far as I can lookup in the dotnet/maui
repo, there is no API for minimizing windows.
Talking to the MAUI team, they suggested that I can access the underlying native objects and do that natively. Here below is my attempts:
Given the MainPage
as a ContentPage
. I have found this:
this.GetParentWindow().Handler.PlatformView
is an instance of UIKit.UIWindow
living in Xamarin.iOS.dll
.
The documentation of UIKit.UIWindow
also has no way to minimize it.
The closest thing that I could find is NSWindow.PerformMiniaturize, that requires a NSWindow, not a UIWindow. That NSWindows seems to be in a thing called AppKit, not UIKit.
This branch contains my attempt to port the application, the WPF application that I am trying to port is right next to it. This is not a huge application, but still quite some amount of code that is unnecessary for this question. If the community provides a tiny sample with a button that when it is clicked the window will minimize, that is good enough I can take it from there.
Thanks a lot in advance.