diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/TypeEditorAttribute.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/TypeEditorAttribute.cs new file mode 100644 index 00000000..26bbd28f --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/TypeEditorAttribute.cs @@ -0,0 +1,18 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Attributes +{ + public class TypeEditorAttribute : Attribute + { + public Type Type { get; set; } + + public TypeEditorAttribute(Type type) + { + var valueSourceInterface = type.GetInterface("Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor"); + if (valueSourceInterface == null) + throw new ArgumentException("Type must implement the ITypeEditor interface.", "type"); + + Type = type; + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs index c868c7f0..fa2c828b 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs @@ -414,7 +414,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid private FrameworkElement GetTypeEditor(PropertyItem propertyItem) { - //first check for any attribute editor + //first check for an attribute editor FrameworkElement editor = GetAttibuteEditor(propertyItem); //now look for a custom editor based on editor definitions @@ -432,9 +432,16 @@ namespace Microsoft.Windows.Controls.PropertyGrid { FrameworkElement editor = null; - var attribute = GetAttribute(propertyItem.PropertyDescriptor); - if (attribute != null) - editor = new ItemsSourceEditor(attribute).ResolveEditor(propertyItem); + var itemsSourceAttribute = GetAttribute(propertyItem.PropertyDescriptor); + if (itemsSourceAttribute != null) + editor = new ItemsSourceEditor(itemsSourceAttribute).ResolveEditor(propertyItem); + + var editorAttribute = GetAttribute(propertyItem.PropertyDescriptor); + if (editorAttribute != null) + { + var instance = Activator.CreateInstance(editorAttribute.Type); + editor = (instance as ITypeEditor).ResolveEditor(propertyItem); + } return editor; } diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj index 282f6c85..81859f16 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -237,6 +237,7 @@ True +