Forum Xamarin Xamarin.Forms

Hiding TabbedPage toolbaritems when listview item navigates to next page

GaganSinghGaganSingh USUniversity ✭✭✭

Hi, How do i remove the toolbaritem when an item in a listview is clicked.
The tabbed page has the following code to display toolbaritems

var contactsPage = new NavigationPage (new ContactsTab () { Title = "Contacts" }) { Title = "Contacts", Icon="contacts_icon.png", }; contactsPage.ToolbarItems.Add (new ToolbarItem ("Sign Out", "signout_icon.png", async () => { await Navigation.PopModalAsync (); })); this.Children.Add(contactsPage);

In the ContactsTab page, there is a listview with contacts and when clicked, it navigates to the profile page. But i want to remove the sign out toolbaritem when it navigates and redisplay it when the back button is pressed.

public async void OnListViewItemTapped(object sender, ItemTappedEventArgs e) { BasicContact profile = (BasicContact)e.Item; await Navigation.PushAsync(new ProfilePage (profile)); ((ListView)sender).SelectedItem = null; FreeVariables.fv.isProfileOpen = true; // Remove ToolbarItem here or remove on Profile page OnAppearing event }

Any suggestions?


  • AlyssaJenkinsonAlyssaJenkinson GBMember
    edited May 2015

    Can you keep a reference to your ToolbarItem and then call:


    Then when you go back to the Contacts page you can add the ToolbarItem again in something like the OnAppearing method.

  • GaganSinghGaganSingh USUniversity ✭✭✭

    ToolbarItems.Remove(new MainPage().SignOutToolbarItem);
    Tries to remove the toolbaritem of the ContentPage (which is the Profile page).
    And it needs to access the TabbedPage's Toolbaritem.

  • vsasavsasa BAMember

    Is there a better way for doing this with the latest version or it's still the same by removing and adding tabbar items?

Sign In or Register to comment.