title: Creating a windowless menu-bar icon application in Monomac/Xamarin C#
body: <p>I am attempting to create an application in MonoMac/Xamarin.Mac that does not have a dock icon, nor a visible window when it launches and only an icon in the top-right menu bar.</p>
  
  <p>I have set LSUIElement = 1 (tried both String and Boolean types) in Info.plist, but the status menu icon isn't displayed at all when the application launches. The only way I can get it to appear is by removing the LSUIElement flag, although then the dock icon becomes visible.</p>
  
  <p>The snippet I am using is:</p>
  
  <pre><code>public partial class AppDelegate : NSApplicationDelegate
  {
      public AppDelegate ()
      {
      }
  
      public override void FinishedLaunching (NSObject notification)
      {
          // Construct menu that will be displayed when tray icon is clicked
          var notifyMenu = new NSMenu();
          var exitMenuItem = new NSMenuItem("Quit", 
                                            (a,b) =&gt; { System.Environment.Exit(0); }); // Just add 'Quit' command
          notifyMenu.AddItem(exitMenuItem);
  
          // Display tray icon in upper-right-hand corner of the screen
          var sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
          sItem.Menu = notifyMenu;
          sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(
              NSBundle.MainBundle.ResourcePath + @"/menu_connected.png"));
          sItem.HighlightMode = true;
  
          // Remove the system tray icon from upper-right hand corner of the screen
          // (works without adjusting the LSUIElement setting in Info.plist)
          NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Accessory;
      }
  }
  </code></pre>
  
  <p>Does anyone know of a good way of creating a windowless application in MonoMac that doesn't have a dock icon and only a menu bar icon?</p>
  
  <p>Thanks,</p>
  
  <p>BB</p>