Exemple #1
0
        /// <summary>
        /// Overrides the pages OnAppearing event, calls the Viewmodel's
        /// <see cref="MVVMbasics.Viewmodels.BaseViewmodel.OnNavigatedTo">OnNavigatedTo</see> method and passes the
        /// parameters that were defined in the original URI.
        /// </summary>
        protected override void OnAppearing()
        {
            InstantiateViewmodel();

            var app = Application.Current as BaseApplication;

            if (app != null)
            {
                app.CurrentView = this;
            }

            if (Parameters == null)
            {
                Parameters = new ParameterList();
            }
            if (Viewmodel != null)
            {
                MVVMbasics.Services.ViewState viewState;
                if (IsMvvmBasicsBackNavigation())
                {
                    viewState = MVVMbasics.Services.ViewState.Reactivated;
                }
                else
                {
                    viewState = MVVMbasics.Services.ViewState.Activated;
                }
                Viewmodel.OnNavigatedTo(new ParameterList(), Parameters, viewState);
            }

            // Clear the existing list of parameters, otherwise they would again be passed during the next OnNavigatedTo
            // event
            Parameters.Clear();

            base.OnAppearing();
        }
Exemple #2
0
        /// <summary>
        /// Calls the Viewmodel's <see cref="MVVMbasics.Viewmodels.BaseViewmodel.OnNavigatedTo">OnNavigatedTo</see>
        /// method.
        /// </summary>
        private void FireOnNavigatedTo()
        {
            InstantiateViewmodel();
            if (Viewmodel != null)
            {
                Viewmodel.OnNavigatedTo(new ParameterList(), _parameters,
                                        _opening ? ViewState.Activated : ViewState.Reactivated);
            }

            // Clear the existing list of parameters, otherwise they would again be passed on to the next OnNavigatedTo
            // call
            _parameters.Clear();
        }
Exemple #3
0
        /// <summary>
        /// Overrides the pages OnNavigatedTo event, calls the Viewmodel's
        /// <see cref="MVVMbasics.Viewmodels.BaseViewmodel.OnNavigatedTo">OnNavigatedTo</see> method and passes the
        /// parameters that were defined in the original URI.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            InstantiateViewmodel();

            // Store a reference to the current View's main frame within the Application
            // (this reference is needed by the NavigatorService)
            var application = Application.Current as BaseApplication;

            if (application != null)
            {
                application.RootFrame   = this.Frame;
                application.CurrentView = this;
            }

            if (Parameters == null)
            {
                Parameters = new ParameterList();
            }
            if (Viewmodel != null)
            {
                ViewState viewState;
                if (e.NavigationMode != NavigationMode.New || IsMvvmBasicsBackNavigation())
                {
                    viewState = ViewState.Reactivated;
                }
                else
                {
                    viewState = ViewState.Activated;
                }
                Viewmodel.OnNavigatedTo(new ParameterList(), Parameters, viewState);
            }

            // Clear the existing list of parameters, otherwise they would again be passed during the next OnNavigatedTo
            // event
            Parameters.Clear();

            // This is necessary to avoid crashing Visual Studio's visual XAML editor
            if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                Window.Current.VisibilityChanged += OnWindowVisibilityChanged;
            }

            base.OnNavigatedTo(e);
        }