我需要使用对象而不是字符串从一个 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));
}
我不想在 url 中传递文本,我需要传递一个对象而不是像下面这样的对象,有什么方法可以做到这一点吗?
Person p = new person();
uri+=p
在第一页中执行以下操作:
PhoneApplicationService.Current.State["param"] = p;
NavigationService.Navigate(new Uri("/PhonePageOne.xaml", UriKind.Relative));
在第二个中检索参数:
Person p = PhoneApplicationService.Current.State["param"] as Person;
The PhoneApplicationService.State
字典是一个临时存储位置,直到您的应用程序停用为止。
其他选项可能是声明静态成员,例如,App.xaml.cs
并使用它来保存一页中的对象并从第二页中检索对象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)