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

            //check for custom editor
            if ((customTypeEditors != null) && (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);
        }
        internal static FrameworkElement GetTypeEditor(PropertyItem propertyItem
                                                       , EditorDefinitionCollection editorDefinitions
                                                       )
        {
            FrameworkElement editor = null;

            //first check for an attribute editor
            if (editor == null)
            {
                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);
        }
Ejemplo n.º 3
0
        public PropertyGrid()
        {
            _properties         = new PropertyItemCollection(new ObservableCollection <PropertyItem>());
            EditorDefinitions   = new EditorDefinitionCollection();
            PropertyDefinitions = new PropertyDefinitionCollection();

            AddHandler(PropertyItem.ItemSelectionChangedEvent, new RoutedEventHandler(OnItemSelectionChanged));
            AddHandler(PropertyItem.ItemOrderingChangedEvent, new RoutedEventHandler(OnItemOrderingChanged));
            CommandBindings.Add(new CommandBinding(PropertyGridCommands.ClearFilter, ClearFilter, CanClearFilter));
        }
        public PropertyGrid()
        {
            _propertyDefinitionsListener = new WeakEventListener <NotifyCollectionChangedEventArgs>(this.OnPropertyDefinitionsCollectionChanged);
            _editorDefinitionsListener   = new WeakEventListener <NotifyCollectionChangedEventArgs>(this.OnEditorDefinitionsCollectionChanged);
            UpdateContainerHelper();
            EditorDefinitions   = new EditorDefinitionCollection();
            PropertyDefinitions = new PropertyDefinitionCollection();

            AddHandler(PropertyItemBase.ItemSelectionChangedEvent, new RoutedEventHandler(OnItemSelectionChanged));
            AddHandler(PropertyItemsControl.PreparePropertyItemEvent, new PropertyItemEventHandler(OnPreparePropertyItemInternal));
            AddHandler(PropertyItemsControl.ClearPropertyItemEvent, new PropertyItemEventHandler(OnClearPropertyItemInternal));
            CommandBindings.Add(new CommandBinding(PropertyGridCommands.ClearFilter, ClearFilter, CanClearFilter));
        }
Ejemplo n.º 5
0
        protected virtual void OnEditorDefinitionsChanged(EditorDefinitionCollection oldValue, EditorDefinitionCollection newValue)
        {
            if (oldValue != null)
            {
                CollectionChangedEventManager.RemoveListener(oldValue, _editorDefinitionsListener);
            }

            if (newValue != null)
            {
                CollectionChangedEventManager.AddListener(newValue, _editorDefinitionsListener);
            }

            this.Notify(this.PropertyChanged, () => this.EditorDefinitions);
        }
Ejemplo n.º 6
0
        protected virtual void OnEditorDefinitionsChanged(EditorDefinitionCollection oldValue, EditorDefinitionCollection newValue)
        {
            if (oldValue != null)
            {
                oldValue.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnEditorDefinitionsCollectionChanged);
            }

            if (newValue != null)
            {
                newValue.CollectionChanged += new NotifyCollectionChangedEventHandler(OnEditorDefinitionsCollectionChanged);
            }

            UpdateProperties(true);
        }
Ejemplo n.º 7
0
 public PropertyGrid()
 {
     EditorDefinitions   = new EditorDefinitionCollection();
     PropertyDefinitions = new PropertyDefinitionCollection();
     CommandBindings.Add(new CommandBinding(PropertyGridCommands.ClearFilter, ClearFilter, CanClearFilter));
 }