public void Add(DockWindowViewModel viewModel) { viewModel.PropertyChanged += ViewModel_PropertyChanged; if (!viewModel.IsClosed) { Documents.Add(viewModel); } }
private MenuItemViewModel GetMenuItemViewModel(DockWindowViewModel dockWindowViewModel) { var menuItemViewModel = container.Resolve <MenuItemViewModel>(); menuItemViewModel.IsCheckable = true; menuItemViewModel.Header = dockWindowViewModel.Title; menuItemViewModel.IsChecked = !dockWindowViewModel.IsClosed; dockWindowViewModel.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(DockWindowViewModel.IsClosed)) { menuItemViewModel.IsChecked = !dockWindowViewModel.IsClosed; } }; menuItemViewModel.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(MenuItemViewModel.IsChecked)) { dockWindowViewModel.IsClosed = !menuItemViewModel.IsChecked; } }; return(menuItemViewModel); }