diff --git a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs index 1ac9e1ed5..eafa0b213 100644 --- a/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs +++ b/src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs @@ -29,8 +29,8 @@ public class PropertyGrid : Control 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 @@ public double MinTitleWidth 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 a6e6c0bd8..0189a15e0 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 @@ - +