Hello @Alexander Zühr ,
You are using Xamarin.Mac to build a Mac app, macOS uses Mutiple Document Interface and this is the behavior of macOS.
You can use the native macOS API handler applicationShouldHandleReopen:hasVisibleWindows: method to reopen the closed window.
**Override the NSApplicationDelegate
in AppDelegate.cs
**
public override bool ApplicationShouldHandleReopen(NSApplication sender, bool hasVisibleWindows)
{
if (!hasVisibleWindows){
var sb = NSStoryboard.FromName("Main", null);//Main.storyboard
var controller = sb.InstantiateControllerWithIdentifier("MainWindow") as NSWindowController;// "MainWindow" is the Storyboard ID in WindowController of Main.storyboard.
controller.Window.MakeKeyAndOrderFront(this);//You can change this window(controller.Window) if you have another window in your project
}
return true;
}
Tips: The Storyboard ID
is empty by default in WindowController
of Main.storyboard
, you can set one, refer to the screenshot at Windows in Xamarin.Mac - Xamarin | Microsoft Learn
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.