Open a window using a controller with Xamarin Mac

I have a status menu in the application with a tray icon with the Xamarin Mac. There is no window shown by setting Application is agent (UIElement) to 1. The login window should only be displayed after pressing the menuItem button. (which is associated with an action.)

The following code initialized a new MainWindowController after clicking a button. This action is called because the breakpoint is hit, but the window is not displayed.

partial void OpenLoginWindow(NSMenuItem sender) { var loginController = new MainWindowController(); loginController.Window.MakeKeyAndOrderFront(this); loginController.ShowWindow(this); } 

When I install the Application Agent (UIElement) back to 0. The window is displayed when you click on the dock icon. But when the login item is clicked, the window is initialized, but it is not brought to the fore.

In the file The main nib file name in Info.plist is set to MainMenu, which is not a window file.

+6
source share
1 answer

It seems like this always works. But since the application is set to Application is an Agent (UIElement) , no dock item is displayed or displayed when ALT + TAB'ing. As Xamarin Studio focused, the window was launched in the background.

+2
source

All Articles