0
votes

I have an iOS app written in Xamarin.Forms that uses the Prism NavigationService for navigation. When a user presses the Logout button, navigation returns to the Login Screen. After doing this more than once, the header reappears.

I have been suppressing the NavigationPage header on every screen with the code

NavigationPage.SetHasNavigationBar(this, false);

This works initially. However it stops working after popping off the navigation stack a few times.

On the login page where this occurs, I've also tried adding the following in XAML with the same result.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:local="clr-namespace:BIMSMobile.ViewModels"
             NavigationPage.HasNavigationBar="False"
             x:Class="BIMSMobile.Views.LoginPage">
    <ContentPage.Content>
...

I suppress the NavigationPage header in favor of a custom view that has the Logout button. The logout button has the following handler:

        protected void OnLogoutClicked(object sender, EventArgs e)
        {
                SessionHelper.Instance.SignOutUser();
        }

In the SessionHelper I do the following:

await NavigationService.NavigateAsync("NavigationPage/LoginPage");

The blue header is suppressed when the app is opened and is maintained for the first few back navigations (pop). I expect this to always be the case. However after the second time of logging out the default header reappears, push the rest of my content down on the screen.

1

1 Answers

0
votes

Apparently this was not caused by Navigation or by incorrectly calling SetHasNavigationBar in code. It was caused by styles in the resources :\ My fix is below.

       <Style TargetType="NavigationPage">
            <Setter Property="HasNavigationBar" Value="False" />
       </Style>