コード例 #1
0
		private PivotViewerHistory(PivotViewer pivotViewer, Uri initialCollectionUri)
		{
			_pivotViewer = pivotViewer;
			_history = new Dictionary<string, PivotViewerHistoryEntry>();
			_currentHistoryEntry = new PivotViewerHistoryEntry(initialCollectionUri, string.Empty);

			_pivotViewer.PropertyChanged += OnPropertyChanged;
			App.Current.Host.NavigationStateChanged += OnHostNavigationStateChanged;
		}
コード例 #2
0
		private void PivotViewerNavigation(string oldNavigationState, string newNavigationState)
		{
			if (!newNavigationState.StartsWith("/viewerStateKey/") && !string.IsNullOrEmpty(newNavigationState))
				return;

			PivotViewerHistoryEntry newEntry = null;

			if (_history.TryGetValue(newNavigationState, out newEntry)
				&& (_pivotViewer.CollectionUri != newEntry.CollectionUri
					|| _pivotViewer.ViewerState != newEntry.ViewerState))
			{
				// There is a mapping from the navigation state to a travel log entry, and the state in the travel log entry
				// is different from the current PivotViewer state, so apply the travel log entry state to get the appropriate
				// forward/back effect

				_isNavigating = true;
				_hasItemIdBeenUpdatedFromCollectionLoad = false;

				// Before updating the ViewerState, update the mapping from navigation state to refer to the current ViewerState
				AddCurrentStateToTravelLog(oldNavigationState);

				// Load the collection and ViewerState in the travel log entry, and set the targeted focus item which will be focused
				// once the new ViewerState has settled
				_pivotViewer.LoadCollection(newEntry.CollectionUri.ToString(), newEntry.ViewerState);
				_pivotViewer.CurrentItemId = newEntry.CurrentItem;

				// Build up a new current entry for the state that will be loaded
				_currentHistoryEntry = new PivotViewerHistoryEntry(newEntry.CollectionUri, newEntry.ViewerState);
			}
			else
			{
				// There is no mapping, or the state is the same as the existing state (for example, user moved from grid view
				// to graph view, and back to grid view, then uses the travel log dropdown to back up two entries in one step,
				// this should result in no state change to PivotViewer, except for possibly a current item change)
				if (newEntry != null)
				{
					AddCurrentStateToTravelLog(oldNavigationState, _pivotViewer.CurrentItemId);
					_pivotViewer.CurrentItemId = newEntry.CurrentItem;
				}
				else
					AddCurrentStateToTravelLog(oldNavigationState);

				// Build up a new current entry for the existing current state
				_currentHistoryEntry = new PivotViewerHistoryEntry(_pivotViewer.CollectionUri, _pivotViewer.ViewerState);
			}
		}