private MenuItemViewModel GetPanelItemViewModel(DockPanelViewModel panelVM) { var menuItemVM = new MenuItemViewModel(); menuItemVM.IsCheckable = true; menuItemVM.Header = panelVM.Title; menuItemVM.IsChecked = !panelVM.IsClosed; panelVM.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(DockPanelViewModel.IsClosed)) { menuItemVM.IsChecked = !panelVM.IsClosed; } }; menuItemVM.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(MenuItemViewModel.IsChecked)) { panelVM.IsClosed = !menuItemVM.IsChecked; } }; return(menuItemVM); }
private void Panel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { DockPanelViewModel panel = sender as DockPanelViewModel; if (panel != null) { if (e.PropertyName == nameof(DockPanelViewModel.IsClosed)) { if (panel.IsClosed) { Documents.Remove(panel); } else { Documents.Add(panel); } } } }