Example #1
0
        /// <summary>
        /// Does actual navigation - adds journal entry if necessary, etc.
        /// </summary>
        /// <param name="e">Details of the navigation event.</param>
        private void DoNavigation(ViewManagerNavigatedEventArgs e)
        {
            DateTime newTimeOfNavigation     = DateTime.UtcNow;
            TimeSpan timeSinceLastNavigation = newTimeOfNavigation - _lastNavigation;

            if (_contentStateToSave != null && this.IsNewNavigation(e.NavigationMode))
            {
                NavigationService navigationService = NavigationService.GetNavigationService(this);
                if (navigationService != null)
                {
                    CustomContentState contentStateToSave = _contentStateToSave;
                    _contentStateToSave = null;

                    if (timeSinceLastNavigation > TimeSpan.FromSeconds(3) || !e.NewNavigator.ShouldReplaceNavigatorInJournal(e.OldNavigator))
                    {
                        navigationService.AddBackEntry(contentStateToSave);
                    }
                }
            }

            if (e.ContentStateToSave != null)
            {
                _contentStateToSave = e.ContentStateToSave;
            }

            Content         = e.Content;
            _lastNavigation = newTimeOfNavigation;
        }
Example #2
0
        private void cmdRemove_Click(object sender, RoutedEventArgs e)
        {
            if (lstTarget.SelectedIndex != -1)
            {
                // Determine the best name to use in the navigation history.
                NavigationService nav         = NavigationService.GetNavigationService(this);
                string            itemText    = lstTarget.SelectedItem.ToString();
                string            journalName = "Removed " + itemText;

                // Update the journal (using the method shown below.)
                nav.AddBackEntry(GetJournalEntry(journalName));

                // Perform the change.
                lstSource.Items.Add(itemText);
                lstTarget.Items.Remove(itemText);
            }
        }