From eb88719af7e3fcb2604207ee3f40153efa9b3f08 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Thu, 27 Oct 2011 14:42:37 +0000 Subject: [PATCH] PropertyGrid: ExpandableObject editor is now read only. --- .../Implementation/PropertyItem.cs | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs index 216188c0..4f7ad870 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs @@ -186,14 +186,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid #endregion //HasResourceApplied - #region IsReadOnly - - public bool IsReadOnly - { - get { return PropertyDescriptor.IsReadOnly; } - } - - #endregion //IsReadOnly + public bool IsReadOnly { get; private set; } #region IsSelected @@ -253,9 +246,6 @@ namespace Microsoft.Windows.Controls.PropertyGrid private set { _propertyDescriptor = value; - Name = _propertyDescriptor.Name; - DisplayName = _propertyDescriptor.DisplayName; - Category = _propertyDescriptor.Category; _dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor); } } @@ -333,11 +323,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid Instance = instance; BindingPath = bindingPath; - var attribute = PropertyGridUtilities.GetAttribute(PropertyDescriptor); - if (attribute != null && PropertyDescriptor.GetValue(Instance) != null) - { - HasChildProperties = true; - } + SetPropertyDescriptorProperties(); + ResolveExpandableObject(); CommandBindings.Add(new CommandBinding(PropertyItemCommands.ResetValue, ExecuteResetValueCommand, CanExecuteResetValueCommand)); AddHandler(Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(PropertyItem_PreviewMouseDown), true); @@ -405,6 +392,24 @@ namespace Microsoft.Windows.Controls.PropertyGrid Properties = PropertyGridUtilities.GetAlphabetizedProperties(propertyItems); } + private void ResolveExpandableObject() + { + var attribute = PropertyGridUtilities.GetAttribute(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 } }