[Windows Phone 7]如何导航页面和页面间传值

WP7中导航页面:

NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

WP7中页面间传值:

WP7页面间传值跟普通的web页面间的传值很类似。

this.NavigationService.Navigate(new Uri("/Page1.xaml?pagetitle=hello", UriKind.Relative));

另一个页面取值:

this.PageTitle.Text  = NavigationContext.QueryString["pagetitle"].ToString();

当然可以直接利用应用程序状态来存值:

PhoneApplicationService.Current.State["key"] = "value";

还可以用全局变量来存值,直接利用static来实现,但一般不推荐这样方式。

注意:在页面间存取值,尽量在重载事件OnNavigatedFrom和OnNavbigatedTo里面操作。

原文地址:https://www.cnblogs.com/ssqjd/p/1884814.html