public override void Replay(NavigationService navigationService, NavigationMode mode) { ContentControl contentControl = (ContentControl)navigationService.INavigatorHost; contentControl.ApplyTemplate(); DocumentApplicationDocumentViewer documentApplicationDocumentViewer = contentControl.Template.FindName("PUIDocumentApplicationDocumentViewer", contentControl) as DocumentApplicationDocumentViewer; if (documentApplicationDocumentViewer != null) { if (this._state is DocumentApplicationState) { documentApplicationDocumentViewer.StoredDocumentApplicationState = (DocumentApplicationState)this._state; } if (navigationService.Content != null) { IDocumentPaginatorSource documentPaginatorSource = navigationService.Content as IDocumentPaginatorSource; if (documentPaginatorSource != null && documentPaginatorSource.DocumentPaginator.IsPageCountValid) { documentApplicationDocumentViewer.SetUIToStoredState(); } } } }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ /// <summary> /// Used to reset the UI to state of this entry /// </summary> /// <param name="navigationService">NavigationService currently running</param> /// <param name="mode">Navigation direction</param> public override void Replay(NavigationService navigationService, NavigationMode mode) { ContentControl navigator = (ContentControl)navigationService.INavigatorHost; // Find a reference to the DocumentViewer hosted in the NavigationWindow // On initial history navigation in the browser, the window's layout may not have been // done yet. ApplyTemplate() causes the viewer to be created. navigator.ApplyTemplate(); DocumentApplicationDocumentViewer docViewer = navigator.Template.FindName( "PUIDocumentApplicationDocumentViewer", navigator) as DocumentApplicationDocumentViewer; Debug.Assert(docViewer != null, "PUIDocumentApplicationDocumentViewer not found."); if (docViewer != null) { // Set the new state on the DocumentViewer if (_state is DocumentApplicationState) { docViewer.StoredDocumentApplicationState = (DocumentApplicationState)_state; } // Check that a Document exists. if (navigationService.Content != null) { IDocumentPaginatorSource document = navigationService.Content as IDocumentPaginatorSource; // If the document has already been paginated (could happen in the // case of a fragment navigation), then set the DocumentViewer to the // new state that was set. if ((document != null) && (document.DocumentPaginator.IsPageCountValid)) { docViewer.SetUIToStoredState(); } } } }
/// <summary> /// Constructor /// </summary> /// <param name="docViewer">The DocumentApplicationDocumentViewer parent.</param> internal CommandEnforcer(DocumentApplicationDocumentViewer docViewer) { //Create our bindings List. _bindings = new List <PolicyBinding>(_initialBindCount); _docViewer = docViewer; }