diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs index 64774017..28c8de73 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs @@ -8,8 +8,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors protected override void Initialize() { Editor = new CheckBox(); - Editor.Margin = new Thickness(4, 0, 0, 0); - + Editor.Margin = new Thickness(5, 0, 0, 0); ValueProperty = CheckBox.IsCheckedProperty; } } diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs index 6aa57ef1..d69ba25e 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs @@ -7,6 +7,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors protected override void SetEditorProperties() { NumericUpDown nud = (NumericUpDown)Editor; + nud.Maximum = int.MaxValue; + nud.Minimum = int.MinValue; nud.ValueType = typeof(int); nud.FormatString = "F0"; } diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs new file mode 100644 index 00000000..7ee388cd --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class TextBlockEditor : TypeEditor + { + protected override void Initialize() + { + Editor = new TextBlock(); + (Editor as TextBlock).Margin = new System.Windows.Thickness(5, 0, 0, 0); + ValueProperty = TextBlock.TextProperty; + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs index d17188a6..962a3d2c 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs @@ -52,8 +52,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid protected virtual void OnIsCategorizedChanged(bool oldValue, bool newValue) { - LoadProperties(newValue); - SetDragThumbMargin(); + InitializePropertyGrid(newValue); } #endregion //IsCategorized @@ -104,8 +103,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid _propertyItemsCache = GetObjectProperties(newValue); - LoadProperties(IsCategorized); - SetDragThumbMargin(); + InitializePropertyGrid(IsCategorized); } #endregion //SelectedObject @@ -146,13 +144,33 @@ namespace Microsoft.Windows.Controls.PropertyGrid #region SelectedObjectName - public static readonly DependencyProperty SelectedObjectNameProperty = DependencyProperty.Register("SelectedObjectName", typeof(string), typeof(PropertyGrid), new UIPropertyMetadata(string.Empty)); + public static readonly DependencyProperty SelectedObjectNameProperty = DependencyProperty.Register("SelectedObjectName", typeof(string), typeof(PropertyGrid), new UIPropertyMetadata(string.Empty, OnSelectedObjectNameChanged, OnCoerceSelectedObjectName)); public string SelectedObjectName { get { return (string)GetValue(SelectedObjectNameProperty); } private set { SetValue(SelectedObjectNameProperty, value); } } + private static object OnCoerceSelectedObjectName(DependencyObject o, object baseValue) + { + if (String.IsNullOrEmpty((String)baseValue)) + return ""; + + return baseValue; + } + + private static void OnSelectedObjectNameChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyGrid = o as PropertyGrid; + if (propertyGrid != null) + propertyGrid.SelectedObjectNameChanged((string)e.OldValue, (string)e.NewValue); + } + + protected virtual void SelectedObjectNameChanged(string oldValue, string newValue) + { + + } + #endregion //SelectedObjectName #region SelectedProperty @@ -237,6 +255,12 @@ namespace Microsoft.Windows.Controls.PropertyGrid #region Methods + private void InitializePropertyGrid(bool isCategorized) + { + LoadProperties(isCategorized); + SetDragThumbMargin(isCategorized); + } + private void LoadProperties(bool isCategorized) { if (isCategorized) @@ -294,7 +318,9 @@ namespace Microsoft.Windows.Controls.PropertyGrid //no custom editor found if (editor == null) { - if (propertyItem.PropertyType == typeof(bool)) + if (propertyItem.IsReadOnly) + editor = new TextBlockEditor(); + else if (propertyItem.PropertyType == typeof(bool)) editor = new CheckBoxEditor(); else if (propertyItem.PropertyType == typeof(int)) editor = new IntegerUpDownEditor(); @@ -367,12 +393,12 @@ namespace Microsoft.Windows.Controls.PropertyGrid } } - private void SetDragThumbMargin() + private void SetDragThumbMargin(bool isCategorized) { if (_dragThumb == null) return; - if (IsCategorized) + if (isCategorized) _dragThumb.Margin = new Thickness(6, 0, 0, 0); else _dragThumb.Margin = new Thickness(-1, 0, 0, 0); diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml index 5979294b..cafcdcb6 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml @@ -305,9 +305,8 @@ - - : - + + diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj index bb693fec..f15199aa 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -179,6 +179,7 @@ +