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

No files matched your search

@@ -29,8 +29,8 @@ namespace HandyControl.Controls
public PropertyGrid() public PropertyGrid()
{ {
CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory)); CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory, (s, e) => e.CanExecute = ShowSortButton));
CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName)); CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName, (s, e)=> e.CanExecute = ShowSortButton));
} }
public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver(); public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver();
@@ -93,6 +93,15 @@ namespace HandyControl.Controls
set => SetValue(MinTitleWidthProperty, value); 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() public override void OnApplyTemplate()
{ {
if (_searchBar != null) if (_searchBar != null)
@@ -132,7 +132,7 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<DockPanel LastChildFill="True" Margin="0,0,0,6"> <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"> <RadioButton Command="interactivity:ControlCommands.SortByCategory" IsChecked="True">
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/> <Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/>
</RadioButton> </RadioButton>
@@ -140,7 +140,7 @@
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByNameDrawingBrush}"/> <Rectangle Width="16" Height="16" Fill="{StaticResource SortByNameDrawingBrush}"/>
</RadioButton> </RadioButton>
</hc:ButtonGroup> </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> </DockPanel>
<ScrollViewer Grid.Row="1"> <ScrollViewer Grid.Row="1">
<hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}"> <hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">