From 594e86730d8fe4bf26f07d48d02b54fe321be773 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 7 Oct 2020 11:02:27 +0800 Subject: [PATCH] fixed #487 --- .../Controls/PropertyGrid/PropertyGrid.cs | 13 +++++++++++-- .../Themes/Styles/Base/PropertyGridBaseStyle.xaml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs index 1ac9e1ed..eafa0b21 100644 --- a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs +++ b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs @@ -29,8 +29,8 @@ namespace HandyControl.Controls public PropertyGrid() { - CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory)); - CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName)); + CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory, (s, e) => e.CanExecute = ShowSortButton)); + CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName, (s, e)=> e.CanExecute = ShowSortButton)); } public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver(); @@ -93,6 +93,15 @@ namespace HandyControl.Controls set => SetValue(MinTitleWidthProperty, value); } + public static readonly DependencyProperty ShowSortButtonProperty = DependencyProperty.Register( + "ShowSortButton", typeof(bool), typeof(PropertyGrid), new PropertyMetadata(ValueBoxes.TrueBox)); + + public bool ShowSortButton + { + get => (bool) GetValue(ShowSortButtonProperty); + set => SetValue(ShowSortButtonProperty, value); + } + public override void OnApplyTemplate() { if (_searchBar != null) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml index a6e6c0bd..0189a15e 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml @@ -132,7 +132,7 @@ - + @@ -140,7 +140,7 @@ - +