I am writing a Xamarin macOs C# app, and want to "duplicate" the main window (i.e. create a new identical window) - I thought I'd create a new instance of the current main window, but nothing I tried seems to work (the window doesn't open) and the documentation/forums/Q&A websites weren't much help. (Please note that i want to duplicate the main window, so all the contents and behaviors should remain the same)
I tried re-instancing the main window's controller and spawning it that way, but that just did nothing:
// Create a new instance of the window controller
var windowController = new MainWindowController();
// Initialize the new window
windowController.Init();
windowController.Load();
// Make the new window the key window
windowController.Window.MakeKeyAndOrderFront(this);
I tried getting a new storyboard and instancing it from there, but still nothing:
// Get the main storyboard
var storyboard = NSStoryboard.FromName("main_storyboard", null);
// Get the window controller
var windowController = storyboard.InstantiateControllerWithIdentifier("MainWindow") as NSWindowController;
// Focus the window and bring it on top
windowController.Window.MakeKeyAndOrderFront(this);
I am kind of new to Xamarin, so sorry if I missed something-
I have never tried duplicating the MainWindow. But I have other windows. Some from storyboards, some from Xib and some created completely programaticaly. In some cases it is required to call ShowWindow():