From 64cd77ece0bad1a0af60f077792476fba46b92c6 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 12 Oct 2020 01:09:35 +0800 Subject: [PATCH] fixed #459 --- .../Controls/PropertyGrid/PropertyGrid.cs | 2 +- .../Controls/PropertyGrid/PropertyItem.cs | 11 +---- .../PropertyGrid/PropertyItemsControl.cs | 10 ++++- .../Styles/Base/PropertyGridBaseStyle.xaml | 43 +++++++++++-------- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs index eafa0b213..b31509c0e 100644 --- a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs +++ b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs @@ -126,7 +126,7 @@ private void UpdateItems(object obj) { if (obj == null || _itemsControl == null) return; - _dataView = CollectionViewSource.GetDefaultView(TypeDescriptor.GetProperties(obj).OfType() + _dataView = CollectionViewSource.GetDefaultView(TypeDescriptor.GetProperties(obj.GetType()).OfType() .Where(item => PropertyResolver.ResolveIsBrowsable(item)).Select(CreatePropertyItem) .Do(item => item.InitElement())); diff --git a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItem.cs b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItem.cs index 942078d8c..de3fba4d0 100644 --- a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItem.cs +++ b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItem.cs @@ -6,7 +6,7 @@ namespace HandyControl.Controls { - public class PropertyItem : Control + public class PropertyItem : ListBoxItem { public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( "Value", typeof(object), typeof(PropertyItem), new PropertyMetadata(default(object))); @@ -107,15 +107,6 @@ public FrameworkElement EditorElement set => SetValue(EditorElementProperty, value); } - public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register( - "IsSelected", typeof(bool), typeof(PropertyItem), new PropertyMetadata(ValueBoxes.FalseBox)); - - public bool IsSelected - { - get => (bool)GetValue(IsSelectedProperty); - set => SetValue(IsSelectedProperty, ValueBoxes.BooleanBox(value)); - } - public static readonly DependencyProperty IsExpandedEnabledProperty = DependencyProperty.Register( "IsExpandedEnabled", typeof(bool), typeof(PropertyItem), new PropertyMetadata(ValueBoxes.FalseBox)); diff --git a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItemsControl.cs b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItemsControl.cs index edc14d0cf..aa1219db2 100644 --- a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItemsControl.cs +++ b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItemsControl.cs @@ -2,8 +2,16 @@ namespace HandyControl.Controls { - public class PropertyItemsControl : ItemsControl + public class PropertyItemsControl : ListBox { protected override bool IsItemItsOwnContainerOverride(object item) => item is PropertyItem; + + public PropertyItemsControl() + { +#if !NET40 + VirtualizingPanel.SetIsVirtualizingWhenGrouping(this, true); + VirtualizingPanel.SetScrollUnit(this, ScrollUnit.Pixel); +#endif + } } } \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml index 0189a15e0..766d92376 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml @@ -89,13 +89,32 @@ + + - - - - - -