Silverlight 带有查询字符串的URI映射器不';好像不行

Silverlight 带有查询字符串的URI映射器不';好像不行,silverlight,silverlight-4.0,query-string,uri,Silverlight,Silverlight 4.0,Query String,Uri,我正在尝试设置一个URI映射器,以便最终可以将查询字符串传递给正在加载的xaml页面 以下是我在XAML中定义的内容 <navigation:Frame.UriMapper> <uriMapper:UriMapper> <uriMapper:UriMapping Uri="RequirementOverview/{id}" MappedUri="/View/Pages/RequirementOverview.xaml?id={id}" /&

我正在尝试设置一个URI映射器,以便最终可以将查询字符串传递给正在加载的xaml页面

以下是我在XAML中定义的内容

<navigation:Frame.UriMapper>
    <uriMapper:UriMapper>
         <uriMapper:UriMapping Uri="RequirementOverview/{id}" MappedUri="/View/Pages/RequirementOverview.xaml?id={id}" />
         <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/View/Pages/{pageName}.xaml"/>
    </uriMapper:UriMapper>
</navigation:Frame.UriMapper>

我的意图是,如果您单击诸如“/RequirementOverview/Foo”之类的链接,“Foo”将作为一个查询字符串传递到需求页面,然后我们就可以使用它来发挥我们的魔力

然而,当调用Fame.Navigate(“RequirementOverview/Foo”,UriKind.Relative)时,我总是在这样的页面结束:hostpage.aspx#/RequirementOverview/Foo,并且没有向该页面传递任何查询。相反,它似乎可以工作(导航),但我的navigationContext查询字符串返回空值


我的方法是否不正确?提前感谢。

您在bowser(hostpage.aspx#/RequirementOverview/Foo)中获得的URL是您应该期待的,因为您正在使用映射URI

要获取
QueryString
参数,只需覆盖
OnNavigatedTo
页面,访问
NavigationContext
类成员
page
QueryString
(这是一个
Dictionary
)属性,如下所示:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    try
    {
       var id = int.Parse(NavigationContext.QueryString["id"];
    }
    catch{}
}

希望这有帮助:)

我想知道您是否需要删除“Frame.Navigate”(“RequirementOverview/Foo”,UriKind.Relative)”中的最后一个/in。其他一切对我来说都是正确的。啊,最后一道斜杠是偶然的,我会编辑这篇文章。