Example #1
0
        /// <summary>
        /// Initializes ViewModel after navigated.
        /// </summary>
        /// <param name="message"></param>
        public void Handle(Navigation.EventMessages.NavigatedEventMessage message)
        {
            //WE ARE LISTENING FOR A MESSAGE THAT SAYS WE WERE SUCCESSFULLY NAVIGATED TO.
            //SO WE ONLY CARE ABOUT IT IF WE ARE THE TARGETPAGE CONTENT VIEWMODEL
            if (message.NavigationInfo.TargetPage.ContentViewModel != this)
            {
                return;
            }

            //WE HAVE BEEN SUCCESSFULLY NAVIGATED TO.

            var targetId = Guid.NewGuid();

            History.Events.ThinkingAboutTargetEvent.Publish(targetId);
            DisableNavigationRequestedEventMessage.Publish();
            try
            {
                var suppress = InitializeViewModelAsync();
            }
            finally
            {
                EnableNavigationRequestedEventMessage.Publish();
                History.Events.ThinkedAboutTargetEvent.Publish(targetId);
            }
        }
        /// <summary>
        /// Initializes ViewModel after navigated.
        /// </summary>
        /// <param name="message"></param>
        public void Handle(Navigation.EventMessages.NavigatedEventMessage message)
        {
            //WE ARE LISTENING FOR A MESSAGE THAT SAYS WE WERE SUCCESSFULLY NAVIGATED TO (SHELLVIEW.MAIN == STUDYVIEWMODEL)
            //SO WE ONLY CARE ABOUT NAVIGATED EVENT MESSAGES ABOUT OUR CORE AS DESTINATION.
            if (message.NavigationInfo.ViewModelCoreNoSpaces !=
                ViewModelBase.GetCoreViewModelName(typeof(StudyASongViewModel)))
            {
                return;
            }

            //WE HAVE BEEN SUCCESSFULLY NAVIGATED TO.

            var targetId = Guid.NewGuid();

            History.Events.ThinkingAboutTargetEvent.Publish(targetId);
            try
            {
                InitializeViewModelAsync();
            }
            finally
            {
                History.Events.ThinkedAboutTargetEvent.Publish(targetId);
            }
        }