/// <summary> /// Updates operation collection. /// </summary> private void UpdateOperations() { this.contextMenuOperations = new Collection<MenuItemViewModel>(); MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Add new DiagramClass", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Add-16.png"); mv.Command = AddNewDiagramClassCommand; this.contextMenuOperations.Add(mv); MenuItemViewModel mv2 = new MenuItemViewModel(this.ViewModelStore, "Add new DiagramClass From Template", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/AddTableHS.png"); mv2.Command = AddNewDiagramClassFromTemplateCommand; this.contextMenuOperations.Add(mv2); if (this.SelectedItems.Count > 0) { bool bIsDesignerDiagramSelected = false; // keep track of selection and set command visibility/accessibility // count different types in selection List<string> selectedTypes = new List<string>(); foreach (BaseModelElementViewModel vm in this.SelectedItems) { string typeName = vm.Element.GetType().Name; if (!selectedTypes.Contains(typeName)) selectedTypes.Add(typeName); if (vm.GetHostedElement() is DesignerDiagramClass) { bIsDesignerDiagramSelected = true; } } if (selectedTypes.Count == 1) { if (selectedTypes.Contains("RelationshipShapeClass") || selectedTypes.Contains("MappingRelationshipShapeClass") || selectedTypes.Contains("ShapeClass")) { MenuItemViewModel mvAddProp = new MenuItemViewModel(this.ViewModelStore, "Add new DomainProperty", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32-Add.png"); mvAddProp.Command = AddNewDomainPropertyCommand; this.contextMenuOperations.Add(mvAddProp); } if (selectedTypes.Contains("RelationshipShapeClass")) { this.AddSeparator(); // add new DomainClass MenuItemViewModel mvAddShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add referenced Domain Relationship"); mvAddShapeClass.Command = addNewDomainRLForRLShape; this.contextMenuOperations.Add(mvAddShapeClass); } if (selectedTypes.Contains("DependencyDiagram") || selectedTypes.Contains("SpecificDependencyDiagram")) { this.AddSeparator(); // add new ShapeClass MenuItemViewModel mvAddShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add new Shape Class"); mvAddShapeClass.Command = AddNewShapeClassCommand; this.contextMenuOperations.Add(mvAddShapeClass); } if (selectedTypes.Contains("SpecificElementsDiagram")) { this.AddSeparator(); // add new DomainClass MenuItemViewModel mvAddShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add referenced Domain Class"); mvAddShapeClass.Command = addNewDomainClassSEDCommand; this.contextMenuOperations.Add(mvAddShapeClass); } if (selectedTypes.Contains("DiagramClass") || selectedTypes.Contains("DesignerDiagramClass") || selectedTypes.Contains("ShapeClass")) { this.AddSeparator(); MenuItemViewModel mvAdd = new MenuItemViewModel(this.ViewModelStore, "Add"); this.contextMenuOperations.Add(mvAdd); // add new ShapeClass MenuItemViewModel mvAddShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add new Shape Class"); mvAddShapeClass.Command = AddNewShapeClassCommand; mvAdd.Children.Add(mvAddShapeClass); if (selectedTypes.Contains("DesignerDiagramClass")) { MenuItemViewModel mvAddAdv = new MenuItemViewModel(this.ViewModelStore, "Add Advanced"); this.contextMenuOperations.Add(mvAddAdv); MenuItemViewModel mvAddIncludedDDC = new MenuItemViewModel(this.ViewModelStore, "Add included Designer Diagram Class"); mvAddIncludedDDC.Command = AddIncludedDDCCommand; mvAddAdv.Children.Add(mvAddIncludedDDC); MenuItemViewModel mvAddIncludedDC = new MenuItemViewModel(this.ViewModelStore, "Add imported Diagram Class"); mvAddIncludedDC.Command = AddImportedDCCommand; mvAddAdv.Children.Add(mvAddIncludedDC); } if (!selectedTypes.Contains("ShapeClass")) { // add new RelationshipShapeClass MenuItemViewModel mvAddRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add new Relationship Shape Class"); mvAddRSShapeClass.Command = AddNewRelationshipShapeClassCommand; mvAdd.Children.Add(mvAddRSShapeClass); // add new MappingRelationshipShapeClass MenuItemViewModel mvAddMappingRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add new Mapping Relationship Shape Class"); mvAddMappingRSShapeClass.Command = AddNewMappingRelationshipShapeClassCommand; mvAdd.Children.Add(mvAddMappingRSShapeClass); } if (selectedTypes.Contains("ShapeClass") && this.SelectedItems.Count == 1) { this.AddSeparator(); MenuItemViewModel mvUnparent = new MenuItemViewModel(this.ViewModelStore, "Unparent"); mvUnparent.Command = UnparentCommand; this.contextMenuOperations.Add(mvUnparent); if (((this.SelectedItems[0] as BaseModelElementViewModel).Element as ShapeClass).DiagramTreeNode is RootDiagramNode) mvUnparent.IsEnabled = false; MenuItemViewModel mvReparent = new MenuItemViewModel(this.ViewModelStore, "Reparent"); mvReparent.Command = ReparentCommand; this.contextMenuOperations.Add(mvReparent); } } if (this.SelectedItems.Count == 1) { if (this.SelectedItems[0] is DiagramTreeNodeViewModel) { #region MoveUp/Down this.AddSeparator(); DiagramTreeNodeViewModel node = this.SelectedItems[0] as DiagramTreeNodeViewModel; if (node != null) { MenuItemViewModel mvMoveUp = new MenuItemViewModel(this.ViewModelStore, "Move up", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Up-16.png"); mvMoveUp.Command = MoveUpCommand; if (!node.CanMoveUp()) mvMoveUp.IsEnabled = false; this.contextMenuOperations.Add(mvMoveUp); MenuItemViewModel mvMoveDown = new MenuItemViewModel(this.ViewModelStore, "Move down", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Down-16.png"); mvMoveDown.Command = MoveDownCommand; if (!node.CanMoveDown()) mvMoveDown.IsEnabled = false; this.contextMenuOperations.Add(mvMoveDown); } #endregion } } } this.AddSeparator(); MenuItemViewModel mvCopy = new MenuItemViewModel(this.ViewModelStore, "Copy", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopy.Command = modelContextVM.CopyCommand; this.contextMenuOperations.Add(mvCopy); MenuItemViewModel mvPaste = new MenuItemViewModel(this.ViewModelStore, "Paste", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Paste.png"); mvPaste.Command = modelContextVM.PasteCommand; this.contextMenuOperations.Add(mvPaste); if (!bIsDesignerDiagramSelected) { this.AddSeparator(); MenuItemViewModel mvDelete = new MenuItemViewModel(this.ViewModelStore, "Delete", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Delete-16.png"); mvDelete.Command = DeleteCommand; this.contextMenuOperations.Add(mvDelete); } // view properties: this.AddSeparator(); MenuItemViewModel mvProp = new MenuItemViewModel(this.ViewModelStore, "Properties", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-16x16.png"); mvProp.Command = ViewPropertiesCommand; this.contextMenuOperations.Add(mvProp); } else { // copy and paste AddSeparator(); MenuItemViewModel mvCopy = new MenuItemViewModel(this.ViewModelStore, "Copy", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopy.Command = modelContextVM.CopyCommand; this.contextMenuOperations.Add(mvCopy); MenuItemViewModel mvPaste = new MenuItemViewModel(this.ViewModelStore, "Paste", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Paste.png"); mvPaste.Command = modelContextVM.PasteCommand; this.contextMenuOperations.Add(mvPaste); } if (this.SelectedItems.Count == 1) { AddSeparator(); MenuItemViewModel mvTemplateHelper = new MenuItemViewModel(this.ViewModelStore, "Template Helper", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/info-16x16.png"); mvTemplateHelper.Command = ShowTemplateHelperCommand; this.contextMenuOperations.Add(mvTemplateHelper); } OnPropertyChanged("Operations"); }
/// <summary> /// Updates operation collection. /// </summary> public virtual void UpdateOperations() { this.contextMenuOperations = new Collection<MenuItemViewModel>(); if (this.IsLocked) { OnPropertyChanged("Operations"); return; } MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Add new DomainClass", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Add-16.png"); mv.Command = AddNewDomainClassCommand; this.contextMenuOperations.Add(mv); if (this.selectedVMS.Count > 0) { bool bIsDomainModelSelected = false; bool bAnyHasBaseClass = false; // keep track of selection and set command visibility/accessibility // count different types in selection List<string> selectedTypes = new List<string>(); foreach (BaseModelElementViewModel vm in this.selectedVMS) { if (vm.GetHostedElement() == null) continue; if (vm.IsLocked) { this.contextMenuOperations.Clear(); if (this.SelectedItems.Count == 1) { BaseModelElementViewModel vmS = this.SelectedItems[0] as BaseModelElementViewModel; if (vmS != null && vmS is TreeNodeViewModel) { TreeNodeViewModel tVm = vmS as TreeNodeViewModel; if (tVm.Parent != null) { if (!tVm.Parent.IsLocked) { #region MoveUp/Down TreeNodeViewModel nodeVM = this.SelectedItems[0] as TreeNodeViewModel; if (nodeVM != null) { MenuItemViewModel mvMoveUp = new MenuItemViewModel(this.ViewModelStore, "Move up", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Up-16.png"); mvMoveUp.Command = MoveUpCommand; if (!nodeVM.CanMoveUp()) mvMoveUp.IsEnabled = false; this.contextMenuOperations.Add(mvMoveUp); MenuItemViewModel mvMoveDown = new MenuItemViewModel(this.ViewModelStore, "Move down", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Down-16.png"); mvMoveDown.Command = MoveDownCommand; if (!nodeVM.CanMoveDown()) mvMoveDown.IsEnabled = false; this.contextMenuOperations.Add(mvMoveDown); } #endregion } } } } OnPropertyChanged("Operations"); return; } string typeName = vm.GetHostedElement().GetType().Name; if (!selectedTypes.Contains(typeName)) selectedTypes.Add(typeName); if (vm.GetHostedElement() is DomainClass) { if ((vm.GetHostedElement() as DomainClass).IsDomainModel) bIsDomainModelSelected = true; if ((vm.GetHostedElement() as DomainClass).BaseClass != null) bAnyHasBaseClass = true; } } bool bCanAddProperties = true; foreach (string t in selectedTypes) if (t != "DomainClass" && t != "ReferenceRelationship" && t != "EmbeddingRelationship" && t != "DomainProperty") { bCanAddProperties = false; break; } if (bCanAddProperties) { MenuItemViewModel mvAddProp = new MenuItemViewModel(this.ViewModelStore, "Add new DomainProperty", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32-Add.png"); mvAddProp.Command = AddNewDomainPropertyCommand; this.contextMenuOperations.Add(mvAddProp); } if (selectedTypes.Count == 1) { if (selectedTypes[0] == "DomainClass") { this.AddSeparator(); #region DomainClass MenuItemViewModel menuItemViewModelAdd = new MenuItemViewModel(this.ViewModelStore, "Add Element/Relationship"); this.contextMenuOperations.Add(menuItemViewModelAdd); // add new embedding relationship MenuItemViewModel mvAddNewEmb = new MenuItemViewModel(this.ViewModelStore, "Add new embedding relationship"); mvAddNewEmb.Command = AddNewEmbeddingRSCommand; menuItemViewModelAdd.Children.Add(mvAddNewEmb); // add new embedding relationship to existing element MenuItemViewModel mvAddNewEmbToEx = new MenuItemViewModel(this.ViewModelStore, "Add new embedding relationship to existing element"); mvAddNewEmbToEx.Command = AddNewEmbeddingRSToExistantCommand; menuItemViewModelAdd.Children.Add(mvAddNewEmbToEx); // add new reference relationship to existing element MenuItemViewModel mvAddNewRef = new MenuItemViewModel(this.ViewModelStore, "Add new reference relationship to existing element"); mvAddNewRef.Command = AddNewReferenceRSCommand; menuItemViewModelAdd.Children.Add(mvAddNewRef); // add new reference relationship to existing relationship MenuItemViewModel mvAddNewRefToRS = new MenuItemViewModel(this.ViewModelStore, "Add new reference relationship to existing relationship"); mvAddNewRefToRS.Command = AddNewReferenceRSToRSCommand; menuItemViewModelAdd.Children.Add(mvAddNewRefToRS); // add new inheritance relationship to existing element MenuItemViewModel mvAddNewInh = new MenuItemViewModel(this.ViewModelStore, "Add new inheritance relationship to existing element"); mvAddNewInh.Command = AddNewInheritanceRSCommand; menuItemViewModelAdd.Children.Add(mvAddNewInh); mvAddNewInh.IsEnabled = !bAnyHasBaseClass; // add new derived class MenuItemViewModel mvAddNewDerived = new MenuItemViewModel(this.ViewModelStore, "Add new derived class"); mvAddNewDerived.Command = AddNewDerivedElementCommand; menuItemViewModelAdd.Children.Add(mvAddNewDerived); MenuItemViewModel menuItemViewModelAddShape = new MenuItemViewModel(this.ViewModelStore, "Add Shape Mapping"); this.contextMenuOperations.Add(menuItemViewModelAddShape); // add new shape mapping MenuItemViewModel mvAddNewShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to new shape class"); mvAddNewShapeClass.Command = AddMappingToNewShapeClassCommand; menuItemViewModelAddShape.Children.Add(mvAddNewShapeClass); // Add new shape mapping to existing shape element MenuItemViewModel mvAddExtShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to existing shape class"); mvAddExtShapeClass.Command = AddMappingToExtShapeClassCommand; menuItemViewModelAddShape.Children.Add(mvAddExtShapeClass); // add new mapping relationship shape mapping MenuItemViewModel mvAddNewMapRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to new mapping relationship shape class"); mvAddNewMapRSShapeClass.Command = AddMappingToNewMappingShapeClassCommand; menuItemViewModelAddShape.Children.Add(mvAddNewMapRSShapeClass); // Add new shape mapping to existing shape element MenuItemViewModel mvAddExtMapRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to existing mapping relationship shape class"); mvAddExtMapRSShapeClass.Command = AddMappingToExtMappingShapeClassCommand; menuItemViewModelAddShape.Children.Add(mvAddExtMapRSShapeClass); if (this.SelectedItems.Count == 1) { TreeNodeViewModel node = this.SelectedItems[0] as TreeNodeViewModel; if (node != null) { AddSeparator(); // bring tree here MenuItemViewModel mvBTH = new MenuItemViewModel(this.ViewModelStore, "Bring tree here"); mvBTH.Command = BringTreeHereCommand; mvBTH.IsEnabled = ModelTreeOperations.CanBringTreeHere(node.TreeNode); this.contextMenuOperations.Add(mvBTH); // split tree MenuItemViewModel mvSplit = new MenuItemViewModel(this.ViewModelStore, "Split tree"); mvSplit.Command = SplitTreeCommand; mvSplit.IsEnabled = ModelTreeOperations.CanSplitTree(node.TreeNode); this.contextMenuOperations.Add(mvSplit); } } #endregion } else if (selectedTypes[0] == "ReferenceRelationship") { this.AddSeparator(); // add new shape mapping MenuItemViewModel mvAddNewRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to new relationship shape class"); mvAddNewRSShapeClass.Command = AddMappingToNewRelShapeClassCommand; this.contextMenuOperations.Add(mvAddNewRSShapeClass); // Add new shape mapping to existing shape element MenuItemViewModel mvAddExtRSShapeClass = new MenuItemViewModel(this.ViewModelStore, "Add mapping to existing relationship shape class"); mvAddExtRSShapeClass.Command = AddMappingToExtRelShapeClassCommand; this.contextMenuOperations.Add(mvAddExtRSShapeClass); } } if (this.SelectedItems.Count == 1) { #region MoveUp/Down AddSeparator(); TreeNodeViewModel nodeVM = this.SelectedItems[0] as TreeNodeViewModel; if (nodeVM != null) { MenuItemViewModel mvMoveUp = new MenuItemViewModel(this.ViewModelStore, "Move up", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Up-16.png"); mvMoveUp.Command = MoveUpCommand; if (!nodeVM.CanMoveUp()) mvMoveUp.IsEnabled = false; this.contextMenuOperations.Add(mvMoveUp); MenuItemViewModel mvMoveDown = new MenuItemViewModel(this.ViewModelStore, "Move down", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Down-16.png"); mvMoveDown.Command = MoveDownCommand; if (!nodeVM.CanMoveDown()) mvMoveDown.IsEnabled = false; this.contextMenuOperations.Add(mvMoveDown); } #endregion } // copy and paste AddSeparator(); //MenuItemViewModel mvCut = new MenuItemViewModel(this.ViewModelStore, "Cut", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Cut.png"); //mvCut.Command = modelContextVM.CutCommand; //this.contextMenuOperations.Add(mvCut); MenuItemViewModel mvCopy = new MenuItemViewModel(this.ViewModelStore, "Copy", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopy.Command = modelContextVM.CopyCommand; this.contextMenuOperations.Add(mvCopy); MenuItemViewModel mvPaste = new MenuItemViewModel(this.ViewModelStore, "Paste", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Paste.png"); mvPaste.Command = modelContextVM.PasteCommand; this.contextMenuOperations.Add(mvPaste); MenuItemViewModel vmAdv = new MenuItemViewModel(this.ViewModelStore, "Advanced"); MenuItemViewModel mvCopyAllTree = new MenuItemViewModel(this.ViewModelStore, "Copy all tree", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopyAllTree.Command = modelContextVM.CopyAllTreeCommand; vmAdv.Children.Add(mvCopyAllTree); MenuItemViewModel mvCopyEmbTree = new MenuItemViewModel(this.ViewModelStore, "Copy with embedding tree", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopyEmbTree.Command = modelContextVM.CopyEmbeddingTreeCommand; vmAdv.Children.Add(mvCopyEmbTree); MenuItemViewModel mvCopyRfTree = new MenuItemViewModel(this.ViewModelStore, "Copy with reference tree", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopyRfTree.Command = modelContextVM.CopyReferenceTreeCommand; vmAdv.Children.Add(mvCopyRfTree); this.contextMenuOperations.Add(vmAdv); // delete: if (!bIsDomainModelSelected) { AddSeparator(); MenuItemViewModel mvDelete = new MenuItemViewModel(this.ViewModelStore, "Delete", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Delete-16.png"); mvDelete.Command = DeleteCommand; this.contextMenuOperations.Add(mvDelete); } // view properties: AddSeparator(); MenuItemViewModel mvProp = new MenuItemViewModel(this.ViewModelStore, "Properties", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-16x16.png"); mvProp.Command = ViewPropertiesCommand; this.contextMenuOperations.Add(mvProp); if (this.SelectedItems.Count == 1) { AddSeparator(); MenuItemViewModel mvTemplateHelper = new MenuItemViewModel(this.ViewModelStore, "Template Helper", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/info-16x16.png"); mvTemplateHelper.Command = ShowTemplateHelperCommand; this.contextMenuOperations.Add(mvTemplateHelper); } } else { // copy and paste AddSeparator(); MenuItemViewModel mvCopy = new MenuItemViewModel(this.ViewModelStore, "Copy", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png"); mvCopy.Command = modelContextVM.CopyCommand; this.contextMenuOperations.Add(mvCopy); MenuItemViewModel mvPaste = new MenuItemViewModel(this.ViewModelStore, "Paste", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Paste.png"); mvPaste.Command = modelContextVM.PasteCommand; this.contextMenuOperations.Add(mvPaste); // optimize AddSeparator(); MenuItemViewModel mvOptimize = new MenuItemViewModel(this.ViewModelStore, "Optimize (beta)"); mvOptimize.Command = modelContextVM.OptimizeCommand; this.contextMenuOperations.Add(mvOptimize); } OnPropertyChanged("Operations"); }
/// <summary> /// Updates operation collection. /// </summary> private void UpdateOperations() { this.contextMenuOperations = new Collection<MenuItemViewModel>(); if (this.SelectedItems.Count == 1) { SerializedDomainClassViewModel classViewModel = this.SelectedItems[0] as SerializedDomainClassViewModel; if( classViewModel != null ) if (classViewModel.Parent != null) { MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Select Relationship"); mv.Command = SelectRelationshipCommand; this.contextMenuOperations.Add(mv); } SerializedReferenceRelationshipViewModel refRelViewModel = this.SelectedItems[0] as SerializedReferenceRelationshipViewModel; if (refRelViewModel != null) if (!refRelViewModel.IsInFullSerialization) { MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Select Relationship"); mv.Command = SelectRelationshipCommand; this.contextMenuOperations.Add(mv); } } if (this.SelectedItems.Count > 0) { AddSeparator(); MenuItemViewModel mvMoveUp = new MenuItemViewModel(this.ViewModelStore, "Move up", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Up-16.png"); mvMoveUp.Command = MoveUpCommand; if (!MoveUpCommand.CanExecute()) mvMoveUp.IsEnabled = false; this.contextMenuOperations.Add(mvMoveUp); MenuItemViewModel mvMoveDown = new MenuItemViewModel(this.ViewModelStore, "Move down", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Down-16.png"); mvMoveDown.Command = MoveDownCommand; if (!MoveDownCommand.CanExecute()) mvMoveDown.IsEnabled = false; this.contextMenuOperations.Add(mvMoveDown); } OnPropertyChanged("Operations"); }