How to change Xamarin back button in menu bar?

♀尐吖头ヾ 提交于 2019-12-06 02:09:40
Daniel Luberda

You can change arrow to hamburger icon if you use your MasterPage within NavigationPage:

Detail = new NavigationPage(masterPage);

If you want to hide icon - it only applies to Android. It can be solved with 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 icon, just change project files:

  • YourProject/Resources/drawable/icon.png
  • YourProject/Resources/drawable-hdpi/icon.png
  • YourProject/Resources/drawable-xhdpi/icon.png
  • YourProject/Resources/drawable-xxhdpi/icon.png

or on your MasterDetailPage set Icon property to another resource.

use the static method SetTitleIcon on the NavigationPage object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!