<Shell
x:Class="MyApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MyApp.Views">
<ShellContent Route="login" FlyoutItemIsVisible="False" ContentTemplate="{DataTemplate views:LoginPage}" />
<ShellContent Route="products" Title="Products" ContentTemplate="{DataTemplate views:ProductsPage}" />
<TabBar>
<Tab Title="Product">
<ShellContent Route="product" ContentTemplate="{DataTemplate views:ProductPage}" />
</Tab>
<Tab Title="Details">
<ShellContent Route="details" ContentTemplate="{DataTemplate views:ProductDetailsPage}" />
</Tab>
</TabBar>
</Shell>
- ProductsPage* 列出了产品。当我单击某个产品时,我希望导航到 ProductPage,其中显示了两个选项卡,可在 ProductPage 和 ProductDetailsPage 之间导航。
在 ProductsPage 的视图模型中,我调用了await Shell.Current.GoToAsync($"product?id={product.Id}")
,这将引发Relative routing to shell elements is currently not supported. Try prefixing your uri with ///: ///product
。
如果我按照建议调用await Shell.Current.GoToAsync($"///product?id={product.Id}")
,我可以导航到 ProductPage,并且可以看到这两个选项卡,但是我看不到返回 ProductsPage 的本机后退箭头。
是否可以从单个页面导航到同一堆栈中的选项卡页面?我的两个选项卡页面的路径是//products/product
和//products/details
,因此我可以从两端导航回 ProductsPage。
1条答案
按热度按时间l2osamch1#
首先,您需要创建Register详细信息页面路径,然后可以使用基于URI的导航从应用中的任何位置导航到这些详细信息页面。
第二,您可以查看本文,了解如何传递数据以及如何使用查询属性特性处理导航数据。