Hide menu icon in Action bar

How do I hide the ActionBar menu icon? I tried it in several ways and in one of them I used ActionBar.SetIcon (null); after LoadApplication (new App (myPage)) but without success.

Answers

  • HarshitaHarshita INMember ✭✭✭✭

    use
    NavigationPage.HasBackButton="False"

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Are there any updates for this issue? If the reply is helpful, please try to mark it as an answer, it will help others who have similar issue.

  • renanbarbosarenanbarbosa Member ✭✭
    edited June 2019

    @Harshita said:
    use
    NavigationPage.HasBackButton="False"

    did not work for me, I'm using version 3.4 of Xamarin.Forms. My project has a hamburger Menu, all navigation is was developed with Prism.

  • renanbarbosarenanbarbosa Member ✭✭

    Update

    Complementing with the code of my project.

    MenuView.xaml

        <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
        prism:ViewModelLocator.AutowireViewModel="True" x:Class="Driver.Views.Menu.Menu" Title="Menu">
    
            <!-- content menu here -->
    
        </MasterDetailPage>
    

    MenuNavigation.xaml

    <NavigationPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
        prism:ViewModelLocator.AutowireViewModel="True"
        x:Class="Driver.Views.Menu.MenuNavigation">
    
    </NavigationPage>
    

    MainPage.xaml

    <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                prism:ViewModelLocator.AutowireViewModel="True"
                x:Class="Driver.Views.MainPage"
                xmlns:LocalServiceOrder="clr-namespace:Driver.Views.Service;assembly=Driver"
                xmlns:LocalHistory="clr-namespace:Driver.Views.History;assembly=Driver"
                Title="MainPage"
                BarBackgroundColor="#03A9F4"
                BarTextColor="White"
                xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
                android:TabbedPage.ToolbarPlacement="Bottom"
                android:TabbedPage.BarItemColor="#66FFFFFF"
                android:TabbedPage.BarSelectedItemColor="White">
    
      <!--Navigation bar-->
        <NavigationPage.TitleView>
    
            <Grid Padding="0,0,18,0">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="70*"/>
            <ColumnDefinition Width="10*"/>
          </Grid.ColumnDefinitions>
    
          <Image x:Name="imgLogo" Grid.Column="0" Grid.Row="0" Source="ic_logo.png" HorizontalOptions="StartAndExpand" Margin="80,0,0,0"/>
          <Image x:Name="imgDriverAvailable" Grid.Column="1" Margin="0,6,0,6" Grid.Row="0" Source="ic_available.png">
            <Image.GestureRecognizers>
              <TapGestureRecognizer Tapped="DriverAvailable_Tapped" />
            </Image.GestureRecognizers>
          </Image>
        </Grid>
    
      </NavigationPage.TitleView>
    
      <TabbedPage.Children>
        <!-- Tab pages here.. -->
      </TabbedPage.Children>
    </TabbedPage>
    

    App.xaml.cs

     protected override void RegisterTypes(IContainerRegistry containerRegistry)
     {
        containerRegistry.RegisterForNavigation<NavigationPage>("Navigation");
        containerRegistry.RegisterForNavigation<MainPage>("MainPage");
        containerRegistry.RegisterForNavigation<Views.Menu.Menu, MenuViewModel>("Menu");
        containerRegistry.RegisterForNavigation<MenuNavigation, MenuNavigationViewModel>("MenuNavigation");
     }
    
  • renanbarbosarenanbarbosa Member ✭✭

    Since I could not find a solution to hide the icon, I decided to hide the entire navigation bar as an alternative, but I need to call the menu in another part of the application.

    How do I make another button perform the same action as the menu icon?
    Thanks!

  • MroboMrobo Member ✭✭

    @renanbarbosa said:
    Since I could not find a solution to hide the icon, I decided to hide the entire navigation bar as an alternative, but I need to call the menu in another part of the application.

    How do I make another button perform the same action as the menu icon?
    Thanks!

    Use this code on your event handler or command (if you are using MVVM)

        private void Button_OnClicked(object sender, EventArgs e)
        {
            if (App.Current.MainPage is MasterDetailPage md)
                md.IsPresented = true;
        }
    
Sign In or Register to comment.