コード例 #1
0
ファイル: MenuViewModel.cs プロジェクト: sanser/carbuy
        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
ファイル: DockManagerViewModel.cs プロジェクト: sanser/carbuy
        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);
                }
            }
        }