Browse Source

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; }
    }
pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
f27e96d16e
  1. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Attributes/ExpandableObjectAttribute.cs
  2. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs
  3. 1
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj

12
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()
{
}
}
}

12
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<ExpandableObjectAttribute>(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<PropertyItem>();

1
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj

@ -237,6 +237,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="BusyIndicator\Implementation\VisualStates.BusyIndicator.cs" />
<Compile Include="PropertyGrid\Implementation\Attributes\ExpandableObjectAttribute.cs" />
<Compile Include="PropertyGrid\Implementation\Attributes\IItemsSource.cs" />
<Compile Include="PropertyGrid\Implementation\Attributes\ItemsSourceAttribute.cs" />
<Compile Include="PropertyGrid\Implementation\Commands\PropertyGridCommands.cs" />

Loading…
Cancel
Save