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

C# 在WP8中使用SQL Server compact传递到另一个页面的数据,c#,wpf,xaml,windows-phone-8,sql-server-ce,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

我已将数据传递到另一个页面,但输出不是我想要的。它显示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;
    }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);

        if (NavigationContext.QueryString.ContainsKey("Select_Item")) 
        { 
            Title.Text = NavigationContext.QueryString["Select_Item"]; 
        }


    }
在ToDoDetailPage.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;
    }
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中

    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;
    }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);

        if (NavigationContext.QueryString.ContainsKey("Select_Item")) 
        { 
            Title.Text = NavigationContext.QueryString["Select_Item"]; 
        }


    }

我认为问题出在您选择的项目上。因为在导航URL中,它是作为字符串传递的。因此,您应该传递所需的参数,例如(所选项目为someClass)。someProperty

问题是我不知道someClass.someProperty应该是什么。我还尝试了字符串select\u Item=MLongListSelector.SelectedItem;但同样的结果出现在SomeClass.someProperty上。这取决于你的控件绑定了什么数据源。你能指导我吗?我需要做什么来搜索呢?因为我在用手机。所以我现在不能写代码了。您可以搜索longlistselector、databind、selectchanged、页面导航等。这对你会有帮助的。如果你有空的时候可以使用笔记本电脑,请这样做,因为我在这个领域还是新手,不知道我应该做什么。谢谢