在WP8中使用SQL Server compact将数据传递到另一个页面

时间:2014-02-10 14:27:31

标签: c# wpf xaml windows-phone-8 sql-server-ce

我已将数据传递到另一页但输出不是我想要的。它显示PhoneApp.ToDoList而不是特定数据。以下是我的代码:

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;
    }

检索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"]; 
        }


    }

这是var select_Item = MLongListSelector.SelectedItem的断点的图像;在MainPage.xaml.cs

1 个答案:

答案 0 :(得分:1)

我认为问题是你的selected_Item。因为在导航URL中,它以字符串形式传递。所以你应该传递你需要的参数,比如(selected_Item as someClass).someProperty