我想導航到傳遞參數的頁面,我必須從主頁面開始工作,但是當我嘗試在較低級別上做類似的事情時,我得到的頁面未找到錯誤(索引頁面工作,但DetailsIndex沒有)Silverlight導航問題
MainPage.xaml中
<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>
MainPage.xaml.cs中(這工作)
this.ContentFrame.Source = new Uri("/index?id=19", UriKind.Relative);
個
IndexPage.xaml.cs(這得到一個錯誤 - >頁面未找到: 「DetailsIndex ID = 66?」)
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
string id = btn.Tag.ToString();
this.NavigationService.Navigate(new Uri(string.Format("DetailsIndex?id={0}", id), UriKind.Relative));
}
謝謝...它確實與「/」一起工作,我有一些非常奇怪的行爲,它是導航在頁面上,然後當我使用導航條件......這拋出了我的錯誤。 我也在討論使用單例模式而不是像這樣傳遞參數......它似乎有點笨拙 – 2009-11-12 23:42:57