internal void layer_EntityDesignerSelectionChanged(object sender, ChangeEntityDesignerSelectionEventArgs e) { if (PackageManager.Package.DocumentFrameMgr != null && PackageManager.Package.DocumentFrameMgr.EditingContextManager != null) { if (PackageManager.Package.DocumentFrameMgr.EditingContextManager.DoesContextExist(_artifact.Uri)) { var editingContext = PackageManager.Package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext( _artifact.Uri); Debug.Assert(editingContext != null, "EditingContext must not be null if we found that a context exists"); if (editingContext != null) { // TODO handle multiple selection at some point var selectedItems = new List <EFNameableItem>(); foreach (var selectionIdentifier in e.SelectionIdentifiers) { if (!String.IsNullOrEmpty(selectionIdentifier)) { var nameableItem = XmlModelHelper.FindNameableItemViaIdentifier( _artifact.ConceptualModel(), selectionIdentifier); if (nameableItem != null) { selectedItems.Add(nameableItem); } } } if (selectedItems.Count > 0) { editingContext.Items.SetValue(new LayerSelection(selectedItems)); } } } } }