示例#1
0
        // Code to execute when the application is deactivated (sent to background)
        // This code will not execute when the application is closing
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            UpdateBindingOnFocusedTextBox();

            var viewModel = ((ViewModelLocator)Current.Resources["Locator"]).Main;

            if (viewModel != null)
            {
                var selectedTask = string.Empty;
                if (viewModel.SelectedTask != null)
                {
                    selectedTask = viewModel.SelectedTask.ToString();
                }

                var draft = string.Empty;
                if (viewModel.SelectedTaskDraft != null)
                {
                    draft = viewModel.SelectedTaskDraft.ToString();
                }

                var state = new TombstoneState(selectedTask, draft);
                if (PhoneApplicationService.Current.State.ContainsKey(StateKey))
                {
                    PhoneApplicationService.Current.State[StateKey] = TombstoneState.ToJson(state);
                }
                else
                {
                    PhoneApplicationService.Current.State.Add(StateKey, TombstoneState.ToJson(state));
                }
            }
        }
示例#2
0
        // 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)
        {
            var viewModel = ((ViewModelLocator)Current.Resources["Locator"]).Main;

            if (viewModel != null)
            {
                var state = TombstoneState.FromJson(PhoneApplicationService.Current.State[StateKey].ToString());

                viewModel.SetState(state);
            }

            Messenger.Default.Send(new ApplicationReadyMessage());
        }