How do I change the Xamarin return button on the menu bar?

this is what i have:

enter image description here

this is what i want to get:

enter image description here

If there are no pages in the navigation stack, the title icon will be in the left corner, otherwise there will be a back arrow and a back arrow. I have not found any options to configure it, is it possible at all?

+3


source to share


2 answers


You can change the arrow to a hamburger icon if you use MasterPage

in the NavigationPage:

Detail = new NavigationPage(masterPage);

      

If you want to hide the icon, this only applies to Android. It can be solved with a custom renderer ( http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/ ):

[assembly:ExportRenderer (typeof(NavigationPage), typeof(CustomNavigationRenderer ))]
public class CustomNavigationRenderer : NavigationRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
    {
        base.OnElementChanged (e);

        var actionBar = ((Activity)Context).ActionBar;
        actionBar.SetIcon (Resource.Color.Transparent);
    }
}

      



To change the icon, just change the project files:

  • YourProject / Resources / draw / icon.png
  • YourProject / resources / extractor-hdpi / icon.png
  • YourProject / resources / extractor-xhdpi / icon.png
  • YourProject / resources / extractor-xxhdpi / icon.png

or MasterDetailPage

set the property Icon

to another resource in yours.

+3


source


use the static SetTitleIcon method for the NavigationPage object.



0


source







All Articles