In my Xamarin Forms 5 app, I'm trying to add a ToolbarItem
to a ContentPage
which is a "child" of a TabbedPage
but the ToolbarItem
is not showing.
The key point here is that the app uses AppShell
and the tabs are defined in AppShell.xaml
which looks like this:
<FlyoutItem Title="Home">
<FlyoutItem.Icon>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource HomeIcon}"
Color="White" />
</FlyoutItem.Icon>
<ShellContent Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}" />
</FlyoutItem>
And the home page has three tabs that point to ContentPage
's:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
... // Removed for brevity>
<local:CommercialFeed Title="Feed" />
<local:PersonalCard Title="Card" />
<local:Vendors Title="Vendors" />
</TabbedPage>
I'm now adding a ToolbarItem
in the "Vendors" page but it doesn't show. I read that I need to wrap main page in a NavigationPage
.
I have two issues here:
- Because I'm using AppShell, my code behind looks like this:
MainPage = new AppShell();
. So not sure how to handle this part. I triedMainPage = new NavigationPage(new AppShell());
but this created another issue -- see below -- and it also crashed the app. - I have a login page which is also defined in the
AppShell
. When I tried the above code, I got a nav bar on the login page as well and that's a problem. There shouldn't be a nav bar in the login page.
How do I handle this so that I can have ToolbarItems
in my Vendors page? Thanks.