/// <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(); }
/// <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); }
/// <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); }
/// <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(); }; }
/// <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(); }