如何在Windows Phone 8中使用对象导航?

use*_*145 1 c# windows-phone-7 windows-phone-8

我需要使用Object而不是String从一个xaml页面导航到另一个页面.

目前的代码是:

  private void Border_ManipulationStarted(object sender,    System.Windows.Input.ManipulationStartedEventArgs e)
{
     string uri = "/PhonePageOne.xaml?Text=";
     uri += txtBox.Text;
     NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}
Run Code Online (Sandbox Code Playgroud)

我不想在网址中传递文字,我需要传递一个对象,而不是像下面那样,并以任何方式做到这一点?

Person p = new person();
uri+=p
Run Code Online (Sandbox Code Playgroud)

and*_*ubi 11

在第一页中执行以下操作:

PhoneApplicationService.Current.State["param"] = p;
NavigationService.Navigate(new Uri("/PhonePageOne.xaml", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)

并在第二个检索参数:

Person p = PhoneApplicationService.Current.State["param"] as Person;
Run Code Online (Sandbox Code Playgroud)

PhoneApplicationService.State词典是一直持续到你的应用程序被关闭的临时存储位置.

例如,其他选项可以是声明一个静态成员,App.xaml.cs并使用它从一个页面保存对象并从第二个页面检索.