0
votes

I create a class extending NavigationPage and an android renderer for it.

using System; using Xamarin.Forms;

namespace NoviSportsProt.CustomViews
{
    public class SecondaryNavigationPage : NavigationPage
    {
        public SecondaryNavigationPage(Page root) : base(root)
        {
        }
    }
}

so this is the code. When i do my navigation with my custom class, the page successfully goes to the new page but there is no navigation toolbar.

Example:

-Shows navigation toolbar-

MainPage.MainPageInstance.Navigation.PushAsync(new NavigationPage(new DummyPage()));

-Doesn't show navigation toolbar-

MainPage.MainPageInstance.Navigation.PushAsync(new SecondaryNavigationPage(new DummyPage()));

EDIT:

If i disable export renderer to my NavigationPage, the toolbar shows up but empty

2
Did you try NavigationPage.HasNavigationBar = true;?Muhammad Khan

2 Answers

0
votes

If you didn't add any elements to toolbar u will recive empty toolbar for first page in application (no back arrow because no page to back). Your renderer didn't work because probably you didnt write code whitch is responsible for toolbar.

0
votes

I was having a similar issue. The problem ended up being related to styling. I incorrectly assumed the following would apply to NavigationPage and any class extending it:

var navPageStyle = new Style (typeof(NavigationPage)) {
            Setters = {
                new Setter { Property = NavigationPage.BarBackgroundColorProperty, Value = Color.FromHex ("CD0000") },
                new Setter { Property = NavigationPage.BarTextColorProperty, Value = Color.White },
            }
        };

When I created the same style definition for my custom navigation page, everything looked as expected.