Browse Source

PropertyGrid: ExpandableObject editor is now read only.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
eb88719af7
  1. 37
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs

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

@ -186,14 +186,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid
#endregion //HasResourceApplied #endregion //HasResourceApplied
#region IsReadOnly public bool IsReadOnly { get; private set; }
public bool IsReadOnly
{
get { return PropertyDescriptor.IsReadOnly; }
}
#endregion //IsReadOnly
#region IsSelected #region IsSelected
@ -253,9 +246,6 @@ namespace Microsoft.Windows.Controls.PropertyGrid
private set private set
{ {
_propertyDescriptor = value; _propertyDescriptor = value;
Name = _propertyDescriptor.Name;
DisplayName = _propertyDescriptor.DisplayName;
Category = _propertyDescriptor.Category;
_dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor); _dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor);
} }
} }
@ -333,11 +323,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid
Instance = instance; Instance = instance;
BindingPath = bindingPath; BindingPath = bindingPath;
var attribute = PropertyGridUtilities.GetAttribute<ExpandableObjectAttribute>(PropertyDescriptor); SetPropertyDescriptorProperties();
if (attribute != null && PropertyDescriptor.GetValue(Instance) != null) ResolveExpandableObject();
{
HasChildProperties = true;
}
CommandBindings.Add(new CommandBinding(PropertyItemCommands.ResetValue, ExecuteResetValueCommand, CanExecuteResetValueCommand)); CommandBindings.Add(new CommandBinding(PropertyItemCommands.ResetValue, ExecuteResetValueCommand, CanExecuteResetValueCommand));
AddHandler(Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(PropertyItem_PreviewMouseDown), true); AddHandler(Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(PropertyItem_PreviewMouseDown), true);
@ -405,6 +392,24 @@ namespace Microsoft.Windows.Controls.PropertyGrid
Properties = PropertyGridUtilities.GetAlphabetizedProperties(propertyItems); Properties = PropertyGridUtilities.GetAlphabetizedProperties(propertyItems);
} }
private void ResolveExpandableObject()
{
var attribute = PropertyGridUtilities.GetAttribute<ExpandableObjectAttribute>(PropertyDescriptor);
if (attribute != null && PropertyDescriptor.GetValue(Instance) != null)
{
HasChildProperties = true;
IsReadOnly = true;
}
}
private void SetPropertyDescriptorProperties()
{
Name = PropertyDescriptor.Name;
DisplayName = PropertyDescriptor.DisplayName;
Category = PropertyDescriptor.Category;
IsReadOnly = PropertyDescriptor.IsReadOnly;
}
#endregion //Methods #endregion //Methods
} }
} }

Loading…
Cancel
Save