Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Change left bar button in navigation header for a specific page (iOS)?

$
0
0

I would like to change the left bar button in the navigation header in a custom renderer, but only for a given page. Something like this:

public class CustomNavigationRenderer : NavigationRenderer
    {

        protected override Task<bool> OnPushAsync(Page page, bool animated)
        {
            if (page.GetType() == typeof(SomePage)
            {
                var cancelButton = new UIBarButtonItem(
                    UIBarButtonSystemItem.Cancel,
                    (sender, args) => { do something });

                this.NavigationBar.TopItem.LeftBarButtonItem = cancelButton;
        //this.NavigationItem.SetLeftBarButtonItem(cancelButton, false);    also tried this
            }
            return base.OnPushAsync(page, animated);
        }
    }

This does not seem to work, I do not get any button on the left in the navigation header for SomePage. In the constructor for SomePage, I have

NavigationPage.SetHasBackButton(this, false);


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>