1.创建一个Tabbed Page并将其设置为app的mainPage。
在 App.xaml.cs 中
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MyTabbedPage());
}
2.将contentPage放在包含listview的Tabbed Page中。
例如,我把listview放在MainPage中。
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App8"
x:Class="App8.MyTabbedPage">
<!--Pages can be added as references or inline-->
<ContentPage Title="Tab 1" Icon="xxx.png"/> //set the title and icon of toolbar item
<local:MainPage Title="Tab 1" Icon="xxx.png"/>
<ContentPage Title="Tab 1" Icon="xxx.png"/>
</TabbedPage>
在 MainPage.xaml 中
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App8"
x:Class="App8.MainPage">
<ListView x:Name="listView" ItemTapped="ListView_ItemTapped" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="30">
...
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
3.当您单击列表视图的项目时,导航到包含您的其他列表视图的新内容页面
在 MainPage.xaml.cs 中
private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
{
Navigation.PushAsync(new xxxContentPage(),true);
}