android on c# MAUI调用< TabBar>Shell.Current.GoToAsync(“//Notificaciones”);来自App.xaml.cs

kt06eoxx  于 2023-06-20  发布在  Android
关注(0)|答案(1)|浏览(290)

我在一个C# MAUI应用程序上的AppShell.xaml文件我有一个TabBar与4标签:

  1. <TabBar>
  2. <Tab Title="Saldo"
  3. Icon="Cat.png">
  4. <ShellContent
  5. Route="Saldo"
  6. ContentTemplate="{DataTemplate local:Saldo}"
  7. />
  8. </Tab>
  9. <Tab Title="Pontos"
  10. Icon="dog.png">
  11. <ShellContent
  12. Route="Pontos"
  13. ContentTemplate="{DataTemplate local:Pontos}"
  14. />
  15. </Tab>
  16. <Tab Title="Postos"
  17. Icon="mapa.png">
  18. <ShellContent
  19. Route="Postos"
  20. ContentTemplate="{DataTemplate local:Postos}"
  21. />
  22. </Tab>
  23. <Tab Title="Notificaciones"
  24. Icon="elephant.png">
  25. <ShellContent
  26. Route="Notificaciones"
  27. ContentTemplate="{DataTemplate local:Notificaciones}"
  28. />
  29. </Tab>
  30. </TabBar>

所有工作正常,但问题是,当我收到一个通知,我试图打开通知从App.xaml.cs和工作,但在此之后,4个标签停止导航

  1. CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
  2. {
  3. Shell.Current.GoToAsync("//Notificaciones");
  4. };

如果我使用相同的代码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”,但总是同样的问题。
你知道吗?
问候

oug3syen

oug3syen1#

首先,更改Shell XAML。

  1. ...
  2. <Tab Title="Notificaciones"
  3. Route="Notificaciones" << route goes here
  4. Icon="elephant.png">
  5. <ShellContent
  6. //Route="Notificaciones" << remove this
  7. ContentTemplate="{DataTemplate local:Notificaciones}"
  8. />
  9. </Tab>

第二,将导航更改为:

  1. Shell.Current.GoToAsync("///Notificaciones");

编辑:
澄清一下,你需要把你的标签发送出去.除了其他的一切,每个读它的人都会知道你在努力做什么。
要导航到一个标签页,你必须使用三重斜杠。每个标签都有自己的导航堆栈,您可以像这样从一个切换到另一个。如果你不这样做三重,页面将在您当前的导航堆栈。
这还不错。有时候我是故意这么做的。但在您的情况下,我99.99%肯定您正在尝试实际选择其他选项卡。

展开查看全部

相关问题