You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Xamarin.Forms中如何从Content Page跳转至Tabbed Page的第二个标签页

实现从Content Page跳转到指定TabbedPage第二个标签的方案

你提供的TabbedPage子项从0开始按顺序索引,第二个标签(对应wallet的ExchangeWallet页面)索引为1,根据你的项目导航架构选择对应方案即可:

方案1:TabbedPage为应用根主页面

如果你的TabbedPage是直接作为App.Current.MainPage,或是被NavigationPage包裹作为根页面,直接修改选中索引即可:

// 跳转逻辑写在你的ContentPage后台代码中
if (App.Current.MainPage is TabbedPage mainTab)
{
    mainTab.SelectedIndex = 1;
}
// 如果主页面外层包了NavigationPage,使用下方代码
if (App.Current.MainPage is NavigationPage navRoot && navRoot.RootPage is TabbedPage mainTab)
{
    mainTab.SelectedIndex = 1;
}

方案2:需要导航到新的TabbedPage实例

如果你要从当前ContentPage新开一个TabbedPage页面、默认打开第二个标签,实例化后直接指定选中索引再执行导航即可:

// 替换为你自己定义的TabbedPage类名
var targetTabPage = new MyCustomTabbedPage();
// 指定选中第二个标签
targetTabPage.SelectedIndex = 1;
// 按你项目的导航逻辑执行跳转,比如用NavigationPage导航栈
await Navigation.PushAsync(targetTabPage);
// 如果是要切换主页面就直接赋值
// App.Current.MainPage = targetTabPage;

内容的提问来源于stack exchange,提问作者Mykola2012

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 06:48:03