/// <summary> /// Sets the current view model for the window content. /// </summary> /// <param name="newViewModel">The new view model for the content</param> /// <param name="disposeOldViewModel">True to dispose the old view model</param> public void SetCurrentViewModel(ViewModelObject newViewModel, bool disposeOldViewModel) { if (newViewModel != m_currentViewModel) { if (disposeOldViewModel && m_currentViewModel is not null) { m_currentViewModel.Dispose(); } m_currentViewModel = newViewModel; OnPropertyChanged(nameof(CurrentViewModel)); } }
/// <summary> /// Creates a new <see cref="WindowViewModel" />. /// </summary> /// <param name="viewModel">The current view model for the window content</param> /// <param name="disposeOldViewModel">True to dispose the old view model on replacing it</param> public WindowViewModel(ViewModelObject viewModel = null, bool disposeOldViewModel = true) : base() { m_currentViewModel = viewModel; m_disposeOldViewModel = disposeOldViewModel; }