Exemplo n.º 1
0
 /// <summary>
 /// This method will be called when navigating away from a page. You can use this method to save your view model data in case of a suspension event.
 /// </summary>
 /// <param name="e">The <see cref="NavigatingFromEventArgs"/> instance containing the event data.</param>
 /// <param name="viewModelState">The state of the view model.</param>
 /// <param name="suspending">if set to <c>true</c> you are navigating away from this viewmodel due to a suspension event.</param>
 public virtual void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary <string, object> viewModelState, bool suspending)
 {
     if (viewModelState != null)
     {
         FillStateDictionary(viewModelState, this);
     }
 }
Exemplo n.º 2
0
        private void OnFrameNavigatingFrom(object sender, NavigatingCancelEventArgs e)
        {
            if (_navigatingFromEventHandlers.Count > 0)
            {
                var args = new NavigatingFromEventArgs(e);

                foreach (var handler in _navigatingFromEventHandlers)
                {
                    handler(this, args);
                }
            }
        }
Exemplo n.º 3
0
        public void OnNavigatedFrom_With_No_RestorableStateAttributes()
        {
            var vm = new MockViewModelWithNoRestorableStateAttributes()
            {
                Title = "MyMock",
                Description = "MyDescription",
            };

            var result = new Dictionary<string, object>();

            NavigatingFromEventArgs args = new NavigatingFromEventArgs();

            vm.OnNavigatingFrom(args, result, true);

            Assert.IsTrue(result.Keys.Count == 0);
        }
Exemplo n.º 4
0
 public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary<string, object> viewState, bool suspending)
 {
     this.OnNavigatedFromCommand(viewState, suspending);
 }
        public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary<string, object> viewModelState, bool suspending)
        {
            e.Cancel = _isNavigationDisabled;

            base.OnNavigatingFrom(e, viewModelState, suspending);
        }
Exemplo n.º 6
0
        private void OnFrameNavigatingFrom(object sender, NavigatingCancelEventArgs e)
        {
            if (_navigatingFromEventHandlers.Count > 0)
            {
                var args = new NavigatingFromEventArgs(e);

                foreach (var handler in _navigatingFromEventHandlers)
                    handler(this, args);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Handles the Navigating event of the Frame control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="NavigatingFromEventArgs"/> instance containing the event data.</param>
 private void OnFrameNavigatingFrom(object sender, NavigatingFromEventArgs e)
 {
     NavigateFromCurrentViewModel(e, false);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Navigates away from the current viewmodel.
        /// </summary>
        /// <param name="e">The <see cref="NavigatingFromEventArgs"/> instance containing the event data.</param>
        /// <param name="suspending">True if it is navigating away from the viewmodel due to a suspend event.</param>
        private void NavigateFromCurrentViewModel(NavigatingFromEventArgs e, bool suspending)
        {
            var departingView = _frame.Content as FrameworkElement;
            if (departingView == null) return;
            var frameState = _sessionStateService.GetSessionStateForFrame(_frame);
            var departingViewModel = departingView.DataContext as INavigationAware;

            var viewModelKey = "ViewModel-" + _frame.BackStackDepth;
            if (departingViewModel != null)
            {
                var viewModelState = frameState.ContainsKey(viewModelKey)
                                         ? frameState[viewModelKey] as Dictionary<string, object>
                                         : null;

                departingViewModel.OnNavigatingFrom(e, viewModelState, suspending);
            }
        }