Cross Platform
Android
iOS
Test Cloud

Add a Nav Bar Right Button

This recipe shows how to add a right button to a navigation bar.

Recipe

To add a button to the UINavigationBar using a built-in icon from the UIBarButtonSystemItem enumeration:

this.NavigationItem.SetRightBarButtonItem(
    new UIBarButtonItem(UIBarButtonSystemItem.Action, (sender,args) => {
       // button was clicked
})
, true);

To add a button to the UINavigationBar using a custom image:

this.NavigationItem.SetRightBarButtonItem(
    new UIBarButtonItem(UIImage.FromFile("some_image.png")
    , UIBarButtonItemStyle.Plain
    , (sender,args) => {
       // button was clicked
    })
, true);

Additional Information

To remove the button:

this.NavigationItem.SetRightBarButtonItem(null, true);