Exemple #1
0
        internal static FrameworkElement GetCustomEditor(PropertyItem propertyItem, EditorDefinitionCollection customTypeEditors)
        {
            FrameworkElement editor = null;

            //check for custom editor
            if (customTypeEditors.Count > 0)
            {
                //first check if the custom editor is type based
                EditorDefinition customEditor = customTypeEditors[propertyItem.PropertyType];
                if (customEditor == null)
                {
                    //must be property based
                    customEditor = customTypeEditors[propertyItem.Name];
                }

                if (customEditor != null)
                {
                    if (customEditor.EditorTemplate != null)
                    {
                        editor = customEditor.EditorTemplate.LoadContent() as FrameworkElement;
                    }
                }
            }

            return(editor);
        }
Exemple #2
0
        internal static FrameworkElement GetTypeEditor(PropertyItem propertyItem, EditorDefinitionCollection editorDefinitions)
        {
            //first check for an attribute editor
            FrameworkElement editor = PropertyGridUtilities.GetAttibuteEditor(propertyItem);

            //now look for a custom editor based on editor definitions
            if (editor == null)
            {
                editor = PropertyGridUtilities.GetCustomEditor(propertyItem, editorDefinitions);
            }

            //guess we have to use the default editor
            if (editor == null)
            {
                editor = PropertyGridUtilities.CreateDefaultEditor(propertyItem);
            }

            return(editor);
        }
Exemple #3
0
        internal static FrameworkElement GetCustomEditor(PropertyItem propertyItem, EditorDefinitionCollection customTypeEditors)
        {
            FrameworkElement editor = null;

            //check for custom editor
            if (customTypeEditors.Count > 0)
            {
                //first check if the custom editor is type based
                EditorDefinition customEditor = customTypeEditors[propertyItem.PropertyType];
                if (customEditor == null)
                {
                    //must be property based
                    customEditor = customTypeEditors[propertyItem.Name];
                }

                if (customEditor != null)
                {
                    if (customEditor.EditorTemplate != null)
                    {
                        editor = customEditor.EditorTemplate.LoadContent() as FrameworkElement;
                    }
                }
            }

            var propertyEditAttribute = (from attribute in propertyItem.PropertyDescriptor.Attributes.OfType <PropertyEditorAttribute>()
                                         select attribute).SingleOrDefault();

            if (propertyEditAttribute != null)
            {
                var typeEditor = Activator.CreateInstance(propertyEditAttribute.EditorType) as ITypeEditor;

                editor = typeEditor.ResolveEditor(propertyItem);
            }

            return(editor);
        }
Exemple #4
0
 public PropertyGrid()
 {
     EditorDefinitions   = new EditorDefinitionCollection();
     PropertyDefinitions = new PropertyDefinitionCollection();
     CommandBindings.Add(new CommandBinding(PropertyGridCommands.ClearFilter, ClearFilter, CanClearFilter));
 }