OwnsJournal 破坏了 UriMapper
如果我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
Frame.JournalOwnership
设置为OwnsJournal
基本上会禁用响应 UriMapping 规则的框架,当您在单个应用程序中有多个框架时可以使用它,您选择一个将响应的主框架到 uri 映射规则,其余的应该维护自己的日志,因此您为它们设置OwnsJournal
。否则,所有框架都会响应 URL,并且如果您在单个应用程序中显示 3 个框架,则每个框架都会独立导航到同一视图,这不是所需的行为。
一旦框架具有
OwnsJournal
属性,导航它的唯一方法就是通过调用Navigate
方法从代码中进行导航。如果您希望
Frame
响应 URL 更改,则需要将其 JournalOwnership 保留为Automatic
Setting
Frame.JournalOwnership
toOwnsJournal
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 setOwnsJournal
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 callingNavigate
method.If you want
Frame
to respond to URL changes, you need to leave its JournalOwnership atAutomatic