Browse Source

PropertyGrid: added support for the DisplayNameAttribute

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
cea282dcfd
  1. 3
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs
  2. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs

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

@ -162,7 +162,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid
protected virtual void OnSelectedObjectTypeChanged(Type oldValue, Type newValue) protected virtual void OnSelectedObjectTypeChanged(Type oldValue, Type newValue)
{ {
SelectedObjectTypeName = newValue.Name; DisplayNameAttribute displayNameAttribute = newValue.GetCustomAttributes(false).OfType<DisplayNameAttribute>().FirstOrDefault();
SelectedObjectTypeName = displayNameAttribute == null ? newValue.Name : displayNameAttribute.DisplayName;
} }
#endregion //SelectedObjectType #endregion //SelectedObjectType

12
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs

@ -34,6 +34,17 @@ namespace Microsoft.Windows.Controls.PropertyGrid
public string Description { get { return PropertyDescriptor.Description; } } public string Description { get { return PropertyDescriptor.Description; } }
#region DisplayName
public static readonly DependencyProperty DisplayNameProperty = DependencyProperty.Register("DisplayName", typeof(string), typeof(PropertyItem), new UIPropertyMetadata(null));
public string DisplayName
{
get { return (string)GetValue(DisplayNameProperty); }
set { SetValue(DisplayNameProperty, value); }
}
#endregion //DisplayName
#region Editor #region Editor
public static readonly DependencyProperty EditorProperty = DependencyProperty.Register("Editor", typeof(FrameworkElement), typeof(PropertyItem), new UIPropertyMetadata(null)); public static readonly DependencyProperty EditorProperty = DependencyProperty.Register("Editor", typeof(FrameworkElement), typeof(PropertyItem), new UIPropertyMetadata(null));
@ -137,6 +148,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid
{ {
_propertyDescriptor = value; _propertyDescriptor = value;
Name = _propertyDescriptor.Name; Name = _propertyDescriptor.Name;
DisplayName = _propertyDescriptor.DisplayName;
Category = _propertyDescriptor.Category; Category = _propertyDescriptor.Category;
_dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor); _dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor);
} }

Loading…
Cancel
Save