我在一个C# MAUI应用程序上的AppShell.xaml文件我有一个TabBar与4标签:
<TabBar>
<Tab Title="Saldo"
Icon="Cat.png">
<ShellContent
Route="Saldo"
ContentTemplate="{DataTemplate local:Saldo}"
/>
</Tab>
<Tab Title="Pontos"
Icon="dog.png">
<ShellContent
Route="Pontos"
ContentTemplate="{DataTemplate local:Pontos}"
/>
</Tab>
<Tab Title="Postos"
Icon="mapa.png">
<ShellContent
Route="Postos"
ContentTemplate="{DataTemplate local:Postos}"
/>
</Tab>
<Tab Title="Notificaciones"
Icon="elephant.png">
<ShellContent
Route="Notificaciones"
ContentTemplate="{DataTemplate local:Notificaciones}"
/>
</Tab>
</TabBar>
所有工作正常,但问题是,当我收到一个通知,我试图打开通知从App.xaml.cs和工作,但在此之后,4个标签停止导航
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
Shell.Current.GoToAsync("//Notificaciones");
};
如果我使用相同的代码Shell.Current.GoToAsync(“//Notificaciones”);从里面的任何4页都继续工作,我读了Xamarin.Forms shell 导航(https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation),并尝试所有可能的选项,如“通知”;“/通知”;“//通知”;“///Notificaciones”和/或不去“Notificaciones”或去,并停止工作4标签。
我也试着替换for并使用地址“//Home/Notificaciones”,但总是同样的问题。
你知道吗?
问候
1条答案
按热度按时间oug3syen1#
首先,更改Shell XAML。
第二,将导航更改为:
编辑:
澄清一下,你需要把你的标签发送出去.除了其他的一切,每个读它的人都会知道你在努力做什么。
要导航到一个标签页,你必须使用三重斜杠。每个标签都有自己的导航堆栈,您可以像这样从一个切换到另一个。如果你不这样做三重,页面将在您当前的导航堆栈。
这还不错。有时候我是故意这么做的。但在您的情况下,我99.99%肯定您正在尝试实际选择其他选项卡。