/// <summary>Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called.
        /// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. </summary>
        /// <param name="viewModel">The view model. </param>
        /// <param name="view">The view. </param>
        public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view)
        {
            viewModel.Initialize();

            view.Loaded   += (sender, args) => viewModel.CallOnLoaded();
            view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();
        }
Example #2
0
        /// <summary>Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called.
        /// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. </summary>
        /// <param name="viewModel">The view model. </param>
        /// <param name="view">The view. </param>
        /// <param name="registerForStateHandling">Registers the view model also for state handling
        /// The view model has to implement <see cref="IStateHandlingViewModel"/> and the view must be a <see cref="MtPage"/>. </param>
        public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view, bool registerForStateHandling)
        {
            viewModel.Initialize();

            view.Loaded   += (sender, args) => viewModel.CallOnLoaded();
            view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();

            RegisterViewModelForStateHandling((IStateHandlingViewModel)viewModel, (MtPage)view);
        }
Example #3
0
        /// <summary>Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called. 
        /// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. </summary>
        /// <param name="viewModel">The view model. </param>
        /// <param name="view">The view. </param>
        /// <param name="registerForStateHandling">Registers the view model also for state handling
        /// The view model has to implement <see cref="IStateHandlingViewModel"/> and the view must be a <see cref="MtPage"/>. </param>
        public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view, bool registerForStateHandling)
        {
            viewModel.Initialize();

            view.Loaded += (sender, args) => viewModel.CallOnLoaded();
            view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();

            RegisterViewModelForStateHandling((IStateHandlingViewModel) viewModel, (MtPage) view);
        }
Example #4
0
        /// <summary>Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called.
        /// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. </summary>
        /// <param name="viewModel">The view model. </param>
        /// <param name="view">The view. </param>
        public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view)
        {
            viewModel.Initialize();

            view.Loaded   += (sender, args) => viewModel.CallOnLoaded();
            view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();

            view.Dispatcher.ShutdownStarted += delegate { viewModel.CallOnUnloaded(); };
        }
Example #5
0
        /// <summary>Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called. 
        /// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. </summary>
        /// <param name="viewModel">The view model. </param>
        /// <param name="view">The view. </param>
        public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view)
        {
            viewModel.Initialize();

            view.Loaded += (sender, args) => viewModel.CallOnLoaded();
            view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();
        }