第一次加载程序:
This is App
This is Application_Launching
This is MainPage()
This is OnNavigatedTo
This is MainPage_Loaded()
返回键离开:
This is OnNavigatingFrom
This is OnNavigatedFrom
This is Application_Closing
This is ~MainPage()
Home键离开:
This is OnNavigatingFrom
This is OnNavigatedFrom
This is Application_Deactivated
Home键离开后启动:
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
}
}
原文地址:http://www.cnblogs.com/Yukang1989/archive/2012/11/22/2783121.html