Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How do I not show the navigation bar at the root of a navigation stack?

$
0
0

So I have a NavigationPage. The root is a scrolling list, but I don't need the navigation bar for it, so I'd like to hide it. But when I push detail pages on to the navigation stack, I want to show the navigation bar for those. What's the best way to achieve this?

I noticed a NavigationPage.SetHasNavigationBar(navigationPage, false) but it does not seem to do anything to navigationPage which still shows the navigation bar as always.

In Objective C I just overrode the methods of the view controller like so:

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}

In Xamarin I'm trying something like this:

NavigationPage.SetHasNavigationBar(navigationPage, false);
control.ItemSelected += async (sender, e) => {
    NavigationPage.SetHasNavigationBar(navigationPage, true);
    await navigationPage.PushAsync(GetDetailsPage(e.ItemId));
    NavigationPage.SetHasNavigationBar(navigationPage, false);
};

Thanks for any help!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>