1

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.

Andrew Au
  • 812
  • 7
  • 18
  • See https://stackoverflow.com/q/57123554/199364. Then figure out the c# equivalent. – ToolmakerSteve Jun 04 '22 at 19:14
  • 1
    @ToolmakerSteve, thanks. That looks different though - that post is talking about setting a minimum windows size, but I am thinking about minimizing, as in clicking the yellow button. The windows will completely disappear and went to the icons in the bottom of the screen. – Andrew Au Jun 04 '22 at 20:49
  • oh you are right! Not sure that is possible. "MacCatalyst" does provide MacOS-specific functionality, but, because it originated from iOS APIs (so app devs can have a single codebase), some details don't seem to be there. :( AFAIK, This is a limitation that has to be fixed by Apple, not Maui. – ToolmakerSteve Jun 04 '22 at 20:54

0 Answers0