Пример #1
0
        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);
        }
Пример #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);
                }
            }
        }
Пример #3
0
    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;
    }