1 using Windows.ApplicationModel;
2 using Windows.ApplicationModel.Activation;
3 using Windows.UI.Xaml;
4 using Windows.UI.Xaml.Controls;
5 namespace MetroGrocer {
6 sealed partial class App : Application {
7 //构造函数 控件的初始化
8 public App() {
9 //初始化相应的控件
10 this.InitializeComponent();
11 this.Suspending += OnSuspending;
12 }
13 //开始加载时间
14 protected override void OnLaunched(LaunchActivatedEventArgs args) {
15 if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) {
16 //TODO: Load state from previously suspended application
17 }
18 // Create a Frame to act navigation context and navigate to the first page
19 var rootFrame = new Frame();
20 //首先导航到listPage这个页面 rootFrame.Navigate(typeof(Pages.ListPage));
21 // Place the frame in the current Window and ensure that it is active
22 Window.Current.Content = rootFrame;
23 Window.Current.Activate();
24 }
25 void OnSuspending(object sender, SuspendingEventArgs e) {
26 //TODO: Save application state and stop any background activity
27 }
28 }
29 }
此时不明白这个类的意思,你也不用慌。在第五章的时候,我会这个类如何对整个生命周期的响应给你们做详细的阐述。
②开始编码了
最明了的原因解释是我为何创建这个项目与你平时创建的项目不同。就是我对listpage.xaml。cs进行了编码。相应的源代码如下: