如何在Windows 8手机导航的对象? [英] How to navigate with objects in windows phone 8?
问题描述
我需要从一个XAML页面导航到另一个对象不是一个字符串..
目前的代码是:
私人无效Border_ManipulationStarted(对象发件人,System.Windows.Input.ManipulationStartedEventArgs E)
{
字符串URI =/PhonePageOne.xaml?Text=
URI + = txtBox.Text;
NavigationService.Navigate(新的URI(URI,UriKind.Relative));
}
我不希望传递一个文本中的网址,我需要传递一个对象,而不是像之下,没有办法做到这一点?
人员P =新的人();
URI + = P
在第一页做到以下几点:
PhoneApplicationService.Current.State [参数] = p;
NavigationService.Navigate(新的URI(/ PhonePageOne.xaml,UriKind.Relative));
和第二检索参数:
者p = PhoneApplicationService.Current.State [参数]的人;
的
PhoneApplicationService.State
词典是暂时的存储位置这一直持续到您的应用程序被停用。
其他选项可能宣布在静态成员,例如 App.xaml.cs
,并用它来从一个网页保存对象,并从第二个取回。
I need to navigate from one xaml page to another with an Object not a String ..
present code is :
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));
}
i dont want to pass a text in the url, i need to pass an object instead of that like below , and any way to do this ?
Person p = new person();
uri+=p
In the first page do the following:
PhoneApplicationService.Current.State["param"] = p;
NavigationService.Navigate(new Uri("/PhonePageOne.xaml", UriKind.Relative));
And in the second retrieve the parameter:
Person p = PhoneApplicationService.Current.State["param"] as Person;
The PhoneApplicationService.State
dictionary is a temporary storage location which persists until your app is deactivated.
Other option could be to declare a static member in, for example, App.xaml.cs
and use it to save the object from one page and to retrieve from the second one.
这篇关于如何在Windows 8手机导航的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!