private MenuItemViewModel GetMenuItemViewModel(DockWindowViewModel dockWindowViewModel)
        {
            var menuItemViewModel = new 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);
        }
Beispiel #2
0
        private void DockWindowViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            DockWindowViewModel document = sender as DockWindowViewModel;

            if (e.PropertyName == nameof(DockWindowViewModel.IsClosed))
            {
                if (!document.IsClosed)
                {
                    this.Documents.Add(document);
                }
                else
                {
                    this.Documents.Remove(document);
                }
            }
        }
    private MenuItemViewModel GetMenuItemViewModel(DockWindowViewModel dockWindowViewModel)
    {
      var menuItemViewModel = new 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;
    }