internal FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem) { FrameworkElement editorElement = null; DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition; object definitionKey = null; Type definitionKeyAsType = definitionKey as Type; ITypeEditor editor = null; if (editor == null) { editor = pd.CreateAttributeEditor(); } if (editor != null) { editorElement = editor.ResolveEditor(propertyItem); } if (editorElement == null && definitionKey == null) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem); } if (editorElement == null && definitionKeyAsType == null) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem); } foreach (var edef in this.PropertyContainer.EditorDefinitions.Where(x => x.HasAttribute != null)) { if (propertyItem.PropertyDescriptor.Attributes.Cast <Attribute>().Any(x => x.GetType() == edef.HasAttribute)) { return(edef.GenerateEditingElementInternal(propertyItem)); } } if (editorElement == null) { if (pd.IsReadOnly) { editor = new TextBlockEditor(); } // Fallback: Use a default type editor. if (editor == null) { editor = (definitionKeyAsType != null) ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null) : pd.CreateDefaultEditor(); } Debug.Assert(editor != null); editorElement = editor.ResolveEditor(propertyItem); } return(editorElement); }
internal FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem) { FrameworkElement editorElement = null; DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition; object definitionKey = null; Type definitionKeyAsType = definitionKey as Type; ITypeEditor editor = null; if (editor == null) { editor = pd.CreateAttributeEditor(); } if (editor != null) { editorElement = editor.ResolveEditor(propertyItem); } if ((editorElement == null) && (definitionKey == null) && (propertyItem.PropertyDescriptor != null)) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem); } if (editorElement == null && definitionKeyAsType == null) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem); } if (editorElement == null) { if (propertyItem.IsReadOnly && !ListUtilities.IsListOfItems(propertyItem.PropertyType) && !ListUtilities.IsCollectionOfItems(propertyItem.PropertyType) && !ListUtilities.IsDictionaryOfItems(propertyItem.PropertyType)) { editor = new TextBlockEditor((propertyItem.PropertyDescriptor != null) ? propertyItem.PropertyDescriptor.Converter : null); } // Fallback: Use a default type editor. if (editor == null) { editor = (definitionKeyAsType != null) ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null, propertyItem) : pd.CreateDefaultEditor(propertyItem); } Debug.Assert(editor != null); editorElement = editor.ResolveEditor(propertyItem); } return(editorElement); }
private FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem) { FrameworkElement editorElement = null; DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition; object definitionKey = null; Type definitionKeyAsType = definitionKey as Type; ITypeEditor editor = null; if (pd.IsReadOnly) { editor = new TextBlockEditor(); } if (editor == null) { editor = pd.CreateAttributeEditor(); } if (editor != null) { editorElement = editor.ResolveEditor(propertyItem); } if (editorElement == null && definitionKey == null) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem); } if (editorElement == null && definitionKeyAsType == null) { editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem); } if (editorElement == null) { // Fallback: Use a default type editor. if (editor == null) { editor = (definitionKeyAsType != null) ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null) : pd.CreateDefaultEditor(); } Debug.Assert(editor != null); editorElement = editor.ResolveEditor(propertyItem); } return(editorElement); }