Skip to content

Commit 594e867

Browse files
committed
fixed #487
1 parent 4ef70ba commit 594e867

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public class PropertyGrid : Control
2929

3030
public PropertyGrid()
3131
{
32-
CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory));
33-
CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName));
32+
CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory, (s, e) => e.CanExecute = ShowSortButton));
33+
CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName, (s, e)=> e.CanExecute = ShowSortButton));
3434
}
3535

3636
public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver();
@@ -93,6 +93,15 @@ public double MinTitleWidth
9393
set => SetValue(MinTitleWidthProperty, value);
9494
}
9595

96+
public static readonly DependencyProperty ShowSortButtonProperty = DependencyProperty.Register(
97+
"ShowSortButton", typeof(bool), typeof(PropertyGrid), new PropertyMetadata(ValueBoxes.TrueBox));
98+
99+
public bool ShowSortButton
100+
{
101+
get => (bool) GetValue(ShowSortButtonProperty);
102+
set => SetValue(ShowSortButtonProperty, value);
103+
}
104+
96105
public override void OnApplyTemplate()
97106
{
98107
if (_searchBar != null)

src/Shared/HandyControl_Shared/Themes/Styles/Base/PropertyGridBaseStyle.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@
132132
<RowDefinition/>
133133
</Grid.RowDefinitions>
134134
<DockPanel LastChildFill="True" Margin="0,0,0,6">
135-
<hc:ButtonGroup Style="{StaticResource ButtonGroupSolid}">
135+
<hc:ButtonGroup Margin="0,0,6,0" Visibility="{Binding ShowSortButton,RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonGroupSolid}">
136136
<RadioButton Command="interactivity:ControlCommands.SortByCategory" IsChecked="True">
137137
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/>
138138
</RadioButton>
139139
<RadioButton Command="interactivity:ControlCommands.SortByName">
140140
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByNameDrawingBrush}"/>
141141
</RadioButton>
142142
</hc:ButtonGroup>
143-
<hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" Margin="6,0,0,0" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
143+
<hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
144144
</DockPanel>
145145
<ScrollViewer Grid.Row="1">
146146
<hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">

0 commit comments

Comments
 (0)