Browse Source

PropertyGrid: custom type editors can now target specific properties or a particular type.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
d34bf44016
  1. 14
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/CustomTypeEditorCollection.cs
  2. 3
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CustomTypeEditor.cs
  3. 1
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ICustomTypeEditor.cs
  4. 11
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs

14
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/CustomTypeEditorCollection.cs

@ -19,5 +19,19 @@ namespace Microsoft.Windows.Controls.PropertyGrid
return null;
}
}
public ICustomTypeEditor this[Type targetType]
{
get
{
foreach (var item in Items)
{
if (item.TargetType == targetType)
return item;
}
return null;
}
}
}
}

3
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CustomTypeEditor.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{
@ -12,5 +13,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors
get { return _properties; }
set { _properties = value; }
}
public Type TargetType { get; set; }
}
}

1
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ICustomTypeEditor.cs

@ -7,5 +7,6 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{
ITypeEditor Editor { get; set; }
IList<string> Properties { get; set; }
Type TargetType { get; set; }
}
}

11
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs

@ -266,11 +266,16 @@ namespace Microsoft.Windows.Controls.PropertyGrid
//check for custom editor
if (CustomTypeEditors.Count > 0)
{
ICustomTypeEditor customEditor = CustomTypeEditors[propertyItem.Name];
if (customEditor != null)
//first check if the custom editor is type based
ICustomTypeEditor customEditor = CustomTypeEditors[propertyItem.PropertyType];
if (customEditor == null)
{
editor = customEditor.Editor;
//must be property based
customEditor = CustomTypeEditors[propertyItem.Name];
}
if (customEditor != null)
editor = customEditor.Editor;
}
//no custom editor found

Loading…
Cancel
Save