From f27e96d16e63227b3ef8b66d586e57d4bd568e55 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Fri, 7 Oct 2011 01:04:39 +0000 Subject: [PATCH] PropertyGrid: no longer support the ExpandableObjectConverter syntax for defining a complex property. I have added a new attribute called ExpandableObjectAttribute. The syntax is as follows: public class Person { [Description("First Name")] public string FirstName { get; set; } [Description("Last Name")] public string LastName { get; set; } [ExpandableObject] public Person Spouse { get; set; } } --- .../Attributes/ExpandableObjectAttribute.cs | 12 ++++++++++++ .../PropertyGrid/Implementation/PropertyItem.cs | 12 ++++-------- .../WPFToolkit.Extended/WPFToolkit.Extended.csproj | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/ExpandableObjectAttribute.cs diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/ExpandableObjectAttribute.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/ExpandableObjectAttribute.cs new file mode 100644 index 00000000..bbf9219f --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/ExpandableObjectAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Attributes +{ + public class ExpandableObjectAttribute : Attribute + { + public ExpandableObjectAttribute() + { + + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs index 7a7429ca..3bc621d6 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs @@ -8,6 +8,7 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Markup.Primitives; using Microsoft.Windows.Controls.PropertyGrid.Commands; +using Microsoft.Windows.Controls.PropertyGrid.Attributes; namespace Microsoft.Windows.Controls.PropertyGrid { @@ -334,8 +335,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid if (!IsReadOnly) { - TypeConverter converter = PropertyDescriptor.Converter; - if (converter is ExpandableObjectConverter && PropertyDescriptor.GetValue(Instance) != null) + var attribute = PropertyGridUtilities.GetAttribute(PropertyDescriptor); + if (attribute != null && PropertyDescriptor.GetValue(Instance) != null) { HasChildProperties = true; } @@ -384,12 +385,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid private void GetChildProperties() { - TypeConverter converter = PropertyDescriptor.Converter; - - PropertyDescriptorCollection descriptors = null; - - if (converter is ExpandableObjectConverter) - descriptors = PropertyDescriptor.GetChildProperties(); + PropertyDescriptorCollection descriptors = PropertyDescriptor.GetChildProperties(); var propertyItems = new List(); diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj index d7f60f2d..862120a9 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -237,6 +237,7 @@ True +