Silverlight导航问题
我试图导航到传递参数的页面,我必须从主页上进行操作,但当我尝试在较低级别上执行类似操作时,我会得到一个页面未找到错误(索引页面工作,但DetailsIndex不工作) MainPage.xamlSilverlight导航问题,silverlight,navigation,Silverlight,Navigation,我试图导航到传递参数的页面,我必须从主页上进行操作,但当我尝试在较低级别上执行类似操作时,我会得到一个页面未找到错误(索引页面工作,但DetailsIndex不工作) MainPage.xaml <navigation:Frame.UriMapper> <uriMapper:UriMapper x:Name="myUri"> <uriMapper:UriMapping Uri="" Mapp
<navigation:Frame.UriMapper>
<uriMapper:UriMapper x:Name="myUri">
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="DetailsIndex/{id}" MappedUri="/Views/DetailsIndex.xaml?id={id}"/>
<uriMapper:UriMapping Uri="Index/{id}" MappedUri="/Views/Index.xaml?id={id}"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
IndexPage.xaml.cs(这会得到一个错误->找不到页面:“DetailsIndex?id=66”)
您应该使用Uri导航,而不是使用映射的Uri
this.NavigationService.Navigate(new Uri(string.Format("DetailsIndex/{0}", id), UriKind.Relative));
另外,在映射中的URI中,我相信它们通常以一个前导的/开头。在做了一些调查之后,我发现下面的解决方案对我很有效 Xaml:
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
这样我也可以传递查询字符串谢谢。。。它确实与“/”一起工作,我有一些非常奇怪的行为,当它导航到页面时,当我使用navigationcontext时,出现了错误。。。这让我很震惊。我也在讨论使用单例模式而不是通过这种方式传递参数。。。看起来有点笨重我有点惊讶。。。使用这种模式,您需要的是/Views/CustomersDetails?CustomId=1.xaml,这肯定不存在。也许我弄错了,但我确实有这个问题。
this.NavigationService.Navigate(new Uri(string.Format("DetailsIndex/{0}", id), UriKind.Relative));
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton hyp = sender as HyperlinkButton;
string customer_id = hyp.Tag.ToString();
this.NavigationService.Navigate(new Uri("/CustomerDetails?CustomerId=" + customer_id, UriKind.Relative));
}