protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (_model == null) { DataContext = _model = (App.Current as App).Model; _model.SearchBeginning += new EventHandler(_model_SearchCompleted); _eventWired = true; } }
// Code to execute when the application is activated (brought to foreground) // This code will not execute when the application is first launched private void Application_Activated(object sender, ActivatedEventArgs e) { if (Model == null) { Model = new AppViewModel(); if (PhoneApplicationService.Current.State.ContainsKey("SolutionsState")) { try { var solutions = PhoneApplicationService.Current.State["SolutionsState"] as Word[]; foreach (Word w in solutions) Model.Solutions.Add(w); } catch (Exception) { } } } }
void WordList_Unloaded(object sender, RoutedEventArgs e) { DataContext = _model = null; }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { Model = new AppViewModel(); Model.Solve(); }