0

I have a Xamarin page with a Navigation bar at the top. I keep changing the views on the page with some button clicks, but the page remains the same.

What I need is, when I load a new view (say View A) on this page, I want to add a Back button on the top Nav bar of the page. I saw some forums where they are using Custom page renderers to add Back button.

But here, the page remains the same. Only the view changes. So, I guess I need to use the custom view renderer to add the Navigation button.

How can I achieve this, as NavigationController which I need to add a Nav button is present in Page renderers, not View renderers.

I need some help.

Thanks

Marcus25
  • 863
  • 1
  • 15
  • 31

1 Answers1

0
UIBarButtonItem customButton = new UIBarButtonItem(
                        UIImage.FromFile("Image/image.png"), 
                        UIBarButtonItemStyle.Plain, 
                        (sender, e) =>{
                                        //InitView
                                        });
                    NavigationItem.LeftBarButtonItem = customButton;
                    this.NavigationItem.LeftBarButtonItem.TintColor = UIColor.Orange;
Karan Rami
  • 321
  • 2
  • 11
  • Thanks... This will work. I wrote this in ViewDidAppear method of Page renderer, and it works. But I want to add a button, when a view in main page changes. The page is already loaded in my case. But when the contents of the page( view) changes, I want to add a button in Nav bar. I tried writing it in View renderer but it did not work. Any other help will be appreciated... Thanks – Marcus25 Aug 10 '17 at 06:14