Maui shell 从单个页面导航到选项卡页面导致“当前不支持 shell 元素的相对路由”

inn6fuwd  于 2023-03-09  发布在  Shell
关注(0)|答案(1)|浏览(368)
<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,其中显示了两个选项卡,可在 ProductPageProductDetailsPage 之间导航。

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

l2osamch

l2osamch1#

首先,您需要创建Register详细信息页面路径,然后可以使用基于URI的导航从应用中的任何位置导航到这些详细信息页面。
第二,您可以查看本文,了解如何传递数据以及如何使用查询属性特性处理导航数据。

相关问题