I have passed my data to another page but the output is not the one i wanted. It displayed PhoneApp.ToDoList instead of the specific data. Below is my code:
MainPage.xaml.cs
private void MainLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// If selected item is null (no selection) do nothing
if (MLongListSelector.SelectedItem == null)
return;
var select_Item = MLongListSelector.SelectedItem;
NavigationService.Navigate(new Uri("/ToDoDetailPage.xaml?Select_Item=" + select_Item, UriKind.Relative));
// Navigate to the new page
//NavigationService.Navigate(new Uri("/ToDoDetailPage.xaml", UriKind.Relative));
// Reset selected item to null (no selection)
MLongListSelector.SelectedItem = null;
}
Retrieved on ToDoDetailPage.xaml.cs
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (NavigationContext.QueryString.ContainsKey("Select_Item"))
{
Title.Text = NavigationContext.QueryString["Select_Item"];
}
}
Here is the image for the breakpoint of var select_Item = MLongListSelector.SelectedItem; in MainPage.xaml.cs
I think the problem is your selected_Item. Because in navigation URL, it is passed as string. So you should pass the param you need,like (selected_Item as someClass).someProperty
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.