This commit is contained in:
NaBian 2020-10-07 11:02:27 +08:00
parent 4ef70ba91d
commit 594e86730d
2 changed files with 13 additions and 4 deletions

View File

@ -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)

View File

@ -132,7 +132,7 @@
<RowDefinition/>
</Grid.RowDefinitions>
<DockPanel LastChildFill="True" Margin="0,0,0,6">
<hc:ButtonGroup Style="{StaticResource ButtonGroupSolid}">
<hc:ButtonGroup Margin="0,0,6,0" Visibility="{Binding ShowSortButton,RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonGroupSolid}">
<RadioButton Command="interactivity:ControlCommands.SortByCategory" IsChecked="True">
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/>
</RadioButton>
@ -140,7 +140,7 @@
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByNameDrawingBrush}"/>
</RadioButton>
</hc:ButtonGroup>
<hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" Margin="6,0,0,0" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
<hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
</DockPanel>
<ScrollViewer Grid.Row="1">
<hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">