第一次加载程序:
This is App
This is Application_LaunchingThis is MainPage()This is OnNavigatedToThis is MainPage_Loaded()返回键离开:
This is OnNavigatingFrom
This is OnNavigatedFromThis is Application_ClosingThis is ~MainPage()Home键离开:
This is OnNavigatingFrom
This is OnNavigatedFromThis is Application_DeactivatedHome键离开后启动:
This is Application_Activated
This is OnNavigatedTo以上就是WP8程序开启离开的常用事件运行顺序,仅供像我一样的菜鸟学习;
扩展:上面顺序就可以很好解释下面(为什么NavigationContext在构造函数写的话会出现NullReference):
发送页面发送字符串:NavigationService.Navigate(new Uri("/Page.2xaml?msg=" + textBox1.Text, UriKind.Relative));
接受页面接受字符串:protected override void OnNavigatedTo( System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); string msg = string.Empty; if (NavigationContext.QueryString.TryGetValue("msg", out msg)) { textBlock1.Text = msg } }