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);