Search code examples
iosxamarinxamarin.iosxamarin-studio

Adding left barbutton on navigation controller


I am trying to add the left bar button in navigation controller but it is not working. My code:

this.NavigationController.NavigationBar.TintColor = UIColor.White;
        this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGBA(204,165,99,255);
        this.NavigationController.NavigationItem.SetLeftBarButtonItem(
            new UIBarButtonItem(UIImage.FromFile("hamburger_menu")
            , UIBarButtonItemStyle.Plain
            , (sender, args) => {
                // button was clicked
            })
        , true);

        this.Title = "Dashboard";

I used code from this url. hamburger_menu is an image present in my Assets.


Solution

  • I was reading image with UIImage.FromFile but when I changed it to UIImage.FromBundle, it started working.