Application_Startup函数 this.Startup += this.Application_Startup; 然后-> private void Application_Startup(object sender, StartupEventArgs e) { var mp = new MainPage(); this.RootVisual = mp; IDictionary<string, string> initParams = LoadInitParams(e); // this just adds the init params to the MainPage for demo purposes only foreach (var kv in initParams) { mp.LayoutRoot.Children.Add(new TextBlock { Text = kv.Key, FontStyle = FontStyles.Italic }); mp.LayoutRoot.Children.Add(new TextBlock { Text = kv.Value, Margin = new Thickness(5,0,0,0) }); } } private static IDictionary<string, string> LoadInitParams(StartupEventArgs e) { IDictionary<string, string> initParams; // if running out of browser retrieve 'initParams' from cache if (Application.Current.IsRunningOutOfBrowser) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("initParams.txt", System.IO.FileMode.Open, isf)) { DataContractSerializer ser = new DataContractSerializer(typeof(Dictionary<string, string>)); initParams = (Dictionary<string, string>)ser.ReadObject(stream); } } // otherwise write initParams to cache else { initParams = e.InitParams; using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("initParams.txt", System.IO.FileMode.Create, isf)) { DataContractSerializer ser = new DataContractSerializer(typeof(Dictionary<string, string>)); ser.WriteObject(stream, initParams); } } return initParams; }