Esempio n. 1
0
        private bool NavigateCore <T_VM> (T_VM parameter, Type viewType) where T_VM : ViewModel.Base
        {
            bool navResult;
            var  viewObject = Activator.CreateInstance(viewType);
            var  view       = Contract.AssertIsType <IView> (() => viewObject, viewObject);

            if (CurrentViewModel != null)
            {
                System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs( );
                CurrentViewModel?.OnNavigatingAway(e);
                if (e.Cancel)
                {
                    return(false);
                }
            }

            DoPreNavigate(parameter, typeof(T_VM), view, viewType);

            view.ViewModelObject = parameter;
            CurrentViewModel     = parameter;

            m_didIDoThat = true;
            navResult    = m_frame.Navigate(view);
            return(navResult);
        }
Esempio n. 2
0
        private bool NavigateCore <T_VM> (T_VM parameter, Type viewType) where T_VM : ViewModel.Base
        {
            bool navResult;
            var  viewObject = Activator.CreateInstance(viewType);
            var  view       = Contract.AssertIsType <IView> (() => viewObject, viewObject);

            DoPreNavigate(parameter, typeof(T_VM), view, viewType);

            view.ViewModelObject = parameter;
            CurrentViewModel     = parameter;

            m_didIDoThat = true;
            navResult    = m_frame.Navigate(view);
            return(navResult);
        }
Esempio n. 3
0
        void BasePage_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
        {
            if (m_inViewModelSet)
            {
                return;
            }

            if (e.NewValue != null)
            {
                ViewModel = Contract.AssertIsType <T> (() => e.NewValue, e.NewValue);
            }
            else
            {
                ViewModel = null;
            }
        }