Everything is working fine when I am handling the Tap event of a ListView
item, but when I use this in a TabbedPage
it shows the exception please p
You probably have some code somewhere similar to this in your App.xaml.cs
:
public App()
{
InitializeComponent();
var tabs = new TabbedPage();
tabs.Children.Add(new NavTestPage() { Title = "Tab title" });
MainPage = tabs;
}
Which you should change to:
public App()
{
InitializeComponent();
var tabs = new TabbedPage();
var page = new NavTestPage() { Title = "Page title" };
tabs.Children.Add(new NavigationPage(page) { Title = "Tab title" });
MainPage = tabs;
}
By wrapping in a NavigationPage
you get the option to push pages onto the navigation stack. A TabbedPage
on itself is just tabs with only 1 page per tab. This should give you a structure like this:
TabbedPage
NavigationPage
ContentPage
NavigationPage
ContentPage
NavigationPage
ContentPage
Update:
I guess what you're doing is simply changing ContentPage
to TabbedPage
in your XAML. That's not how TabbedPage
works. You should probably read up on how TabbedPage
actually works in the first place.
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/
In your case you should probably create a new page which has XAML like this:
Set this as the MainPage
in App.xaml.cs
:
public App()
{
InitializeComponent();
MainPage = new MyTabbedPage();
}