Ambar is a macOS Menu Bar app developed with Xamarin and C#. This project aims to show developing a menu bar app for macOS in C#.
Using Ambar as the base, I was able to build Carol - a minimal and beautiful lyrics app for macOS. Check it out.
It is for the folks wanting to start developing for macOS/iOS/tvOS/watchOS but do not want to delve into Swift/Obj-C and are already comfortable with C# and .Net technologies.
- Visual Studio for Mac
Here is how you can do it -
- In Xcode, delete Window Controller Scene from
Main.storyboardand provide Storyboard ID to View Controller.
- Add new entry in info.plist -
Application is agent (UIElement)with its value set to
Yesto make the app behave as a ghost.
- Create a Menu Bar status item using
- Handle status bar icon for dark and light theme using
- Handle event handling of status item using
- Show a popover using
- Make popover show on demand and hide when user moves on using
NSEventand a custom class.
- In Xcode, add a button to View Controller and create an action
control + drag. In VS, call
Unless stated otherwise, everything is done in Visual Studio for Mac.
- Add a Contextual Menu to show options.
- Add a Launch at Login setting.
- Add a About window.
If you think this project can be improved to show more of what can be done using Xamarin and C#, you are welcome to contribute. If you build something epic using it, just let me know.