【问题标题】:How to navigate from a content page to the second tab of Tabbed page in xamarin.forms?如何从内容页面导航到 xamarin.forms 中选项卡式页面的第二个选项卡?
【发布时间】:2021-07-14 10:19:10
【问题描述】:

我想从我的内容页面导航到标签页上的第二个标签。请说我该怎么做

 <TabbedPage.Children>
        <local:MoneyExchangeMainScreen Title="home" IconImageSource="cehome" />
        <local:ExchangeWallet Title="wallet" IconImageSource="cewallet" />
        <NavigationPage Title="prices" IconImageSource="ceprices">
            <x:Arguments>
                <local:MoneyExchangePrice />
            </x:Arguments>

        </NavigationPage>
        <local:ExchangePage Title="exchange" IconImageSource="ceexchange" />
        <local:ExchangePage Title="settings" IconImageSource="cesetting" />
    </TabbedPage.Children>

【问题讨论】:

  • 哪个ContentPage?一个包含在选项卡中,还是其他地方?
  • 此页面不在标签上。一般来说,这个想法是用户应该登录(单独的内容页面),然后他应该转到标签页上的第二个标签
  • 将标签页设置为App的MainPage,并将标签的CurrentPage属性设置为您要显示的标签
  • 如果我想从一个页面进入第二个标签,然后在交易之后(以及一个单独的内容页面)我想进入第三个标签怎么办?
  • 然后再次更改 CurrentPage 属性。但我会质疑这种设计 - 以编程方式在选项卡之间跳转通常不是一个好主意

标签: c# xamarin xamarin.forms xamarin.android frontend


【解决方案1】:

将Tabbedpage设置为App.MainPage,并手动设置其CurrentPage

在单独的内容页面中的某处

 YourTabbed tab = new YourTabbed();
 tab.CurrentPage = tab.Children[1];    //this means going to second tab
 (App.Current as App).MainPage = tab;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多