Prism-Xamarin表单:如何在导航期间保持底部选项卡处于活动状态
我是一个xamarin forms prism应用程序,我有3个选项卡,选项卡栏仅在该特定页面上处于活动状态,如果我深入某个特定选项卡,底部选项卡将消失。有没有一种方法可以使底部选项卡在导航到这些选项卡中的其他页面时始终处于活动状态 我试着做一些类似的事情,但在prism中我做不到 没有prism的话,就像上面的链接所示,这是非常简单的,但我不能用prism。有人能建议我如何实现这一目标吗 我的代码: App.Xaml.csPrism-Xamarin表单:如何在导航期间保持底部选项卡处于活动状态,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我是一个xamarin forms prism应用程序,我有3个选项卡,选项卡栏仅在该特定页面上处于活动状态,如果我深入某个特定选项卡,底部选项卡将消失。有没有一种方法可以使底部选项卡在导航到这些选项卡中的其他页面时始终处于活动状态 我试着做一些类似的事情,但在prism中我做不到 没有prism的话,就像上面的链接所示,这是非常简单的,但我不能用prism。有人能建议我如何实现这一目标吗 我的代码: App.Xaml.cs protected override async void OnIni
protected override async void OnInitialized()
{
InitializeComponent();
await NavigationService.NavigateAsync("NavigationPage/MainPage");
}
MainPage.XML
<?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:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:windows="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core"
xmlns:local="clr-namespace:MyTabs.Common.Views"
x:Class="MyTabs.Common.Views.MainPage" BackgroundColor="Olive" BarBackgroundColor="Maroon">
<TabbedPage.Children>
<local:PageOne Title="PageOne"
Icon="PageOne.png" />
<local:PageTwo Title="PageTwo"
Icon="PageTwo.png" />
<NavigationPage Title="PageThree" Icon="PageThree s.png">
<x:Arguments>
<local: PageThree/>
</x:Arguments>
</NavigationPage>
<local:PageFour Title="PageFour"
Icon="PageFour.png" />
</TabbedPage.Children>
</TabbedPage>
您可以通过使用
导航页面
将内容页面
包装在选项卡页面
中来实现这一点
代码:
<TabbedPage>
<TabbedPage.Children>
<NavigationPage Title="Home" Icon="home.png">
<x:Arguments>
<ContentPage>
//Your ContentPage here
//You can have a ViewModel for this ContentPage and Navigate inside that and will still have the Tabbed Page outside.
</ContentPage>
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
//您的内容页在这里
//您可以拥有此ContentPage的ViewModel,并在其内部导航,但仍可以将选项卡式页面置于外部。
您是否尝试将选项卡内的页面设置为导航页面。这样标签就会粘在周围,我该怎么做?所以只有第三页需要里面的导航?你能把你在第3页导航的代码粘贴到其他页面吗?您还可以尝试删除await NavigationService.NavigateAsync(“NavigationPage/MainPage”)中的NavigationPage;所有页面都需要它,但目前只是测试第三页。这只是一个空白页。未在该页面中添加任何内容。您必须从PageThreeViewModel导航,然后它才能工作。因为我已经完成了sameI尝试了代码
,其中
是内容页,但是当我在NewsFeed中导航时,标签不会粘在底部。你是如何在内部导航的?你能把密码寄出去吗?
<TabbedPage>
<TabbedPage.Children>
<NavigationPage Title="Home" Icon="home.png">
<x:Arguments>
<ContentPage>
//Your ContentPage here
//You can have a ViewModel for this ContentPage and Navigate inside that and will still have the Tabbed Page outside.
</ContentPage>
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>