How to add custom UIBarButtonItem to edit navigation bar.
public UIBarButtonItem btn_Cart {get; set;}
public DetailedController (){
string buttonTitle = "One";
btn_Cart = new UIBarButtonItem (buttonTitle, UIBarButtonItemStyle.Bordered, null);
btn_Cart.Clicked += (s, e) => { new UIAlertView ("click!", "btnOne clicked", null, "OK", null).Show ();
};
}
public override void ViewDidLoad (){
base.ViewDidLoad ();
this.NavigationItem.SetRightBarButtonItem (btn_Cart, true);
}
Its not added to navigationItem.
If I change my code to
public override void ViewDidLoad (){
this.NavigationItem.SetRightBarButtonItem(
new UIBarButtonItem(UIImage.FromBundle ("Image.png")
, UIBarButtonItemStyle.Plain
, (sender,args) => {
new UIAlertView ("click!", "btnOne clicked", null, "OK", null).Show ();
})
, true);
}
// Added to the NavigationItem on the right side.
public class DetailedTabBarController : UITabBarController {
public override void ViewDidLoad (){
base.ViewDidLoad ();
this.NavigationItem.SetRightBarButtonItem(
new UIBarButtonItem(UIImage.FromBundle ("/Images/Image.png"),
UIBarButtonItemStyle.Plain,
(sender,args) => {
Console.WriteLine("Do Some Action!");
}), true);
}
}
I do not want to add that.
Can anyone advise me to add a UIBarButtonItem to the NavigationItem on the right side. @ All thanks in advance ...