OwnsJournal 破坏了 UriMapper

发布于 2024-12-04 10:09:46 字数 659 浏览 0 评论 0原文

如果我对 JournalOwnership 使用 OwnsJournal 选项,则 UriMapping 将停止工作,因为即使 uri 与 id/{guid} 格式匹配,也只会显示 /Views/Main.xaml。有人遇到过这个吗?

<Grid x:Name="root" Background="White">
    <navigation:Frame JournalOwnership="OwnsJournal">
        <navigation:Frame.UriMapper>
            <uriMapper:UriMapper>
                <uriMapper:UriMapping Uri="id/{guid}" MappedUri="/Views/Redirector.xaml?id={guid}" />
                <uriMapper:UriMapping Uri="" MappedUri="/Views/Main.xaml" />
            </uriMapper:UriMapper>
        </navigation:Frame.UriMapper>
    </navigation:Frame>
</Grid>

If I use the OwnsJournal option for JournalOwnership, the UriMapping stops working, as in only /Views/Main.xaml will be shown even if the uri matches the id/{guid} format. Anyone run into this?

<Grid x:Name="root" Background="White">
    <navigation:Frame JournalOwnership="OwnsJournal">
        <navigation:Frame.UriMapper>
            <uriMapper:UriMapper>
                <uriMapper:UriMapping Uri="id/{guid}" MappedUri="/Views/Redirector.xaml?id={guid}" />
                <uriMapper:UriMapping Uri="" MappedUri="/Views/Main.xaml" />
            </uriMapper:UriMapper>
        </navigation:Frame.UriMapper>
    </navigation:Frame>
</Grid>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2024-12-11 10:09:46

Frame.JournalOwnership 设置为 OwnsJournal 基本上会禁用响应 UriMapping 规则的框架,当您在单个应用程序中有多个框架时可以使用它,您选择一个将响应的主框架到 uri 映射规则,其余的应该维护自己的日志,因此您为它们设置 OwnsJournal

否则,所有框架都会响应 URL,并且如果您在单个应用程序中显示 3 个框架,则每个框架都会独立导航到同一视图,这不是所需的行为。

一旦框架具有 OwnsJournal 属性,导航它的唯一方法就是通过调用 Navigate 方法从代码中进行导航。

如果您希望 Frame 响应 URL 更改,则需要将其 JournalOwnership 保留为 Automatic

Setting Frame.JournalOwnership to OwnsJournal basicly disables frame responding to UriMapping rules, it can be used when you have multiple frames in single application, you choose a main frame that will be responding to uri mapping rules, and the rest should maintain their own journal, so you set OwnsJournal for them.

Otherwise all frames would be responding to URL and if you had 3 frames in single application displayed, each would navigate independently to same view, which is not desired behaviour.

Once frame has OwnsJournal property , only way to navigate it is from code by calling Navigate method.

If you want Frame to respond to URL changes, you need to leave its JournalOwnership at Automatic

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文