优化datagrid

This commit is contained in:
chfei committed 2026-10-21 17:11:24 +08:00
1 parent e12c419ef3
commit 233ec5d58d
8 files changed
+429 -57

No files matched your search

+28 -9
View File
@@ -3,16 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ext="clr-namespace:Main.Test"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<!--<FontFamily x:Key="FontFamily">Microsoft YaHei</FontFamily>
-->
<!-- 默认字体大小 -->
<!--
<sys:Double x:Key="DefaultFontSize">14</sys:Double>-->
<Style x:Key="DefaultCellHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="ext:DataGridHelper.ShowBorder" Value="True" />
<!--<Setter Property="ext:DataGridHelper.ShowBorder" Value="True" />-->
<Setter Property="Height" Value="{Binding ColumnHeaderHeight, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
<Setter Property="Background" Value="#eeeeee" />
@@ -165,7 +159,6 @@
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<!-- 选中后颜色改变 -->
<Setter Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
@@ -191,6 +184,11 @@
VerticalAlignment="Center"
TextElement.FontSize="10" />
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True">
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -404,7 +402,28 @@
Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
Background="#eeeeee"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
BorderThickness="1,0,1,1" />
BorderThickness="1,0,1,1">
<CheckBox
Width="32"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
AutomationProperties.Name="全选行"
Command="{x:Static ext:StyledDataGrid.ToggleSelectAllCommand}"
CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type ext:StyledDataGrid}}}"
IsChecked="{Binding AreAllRowsSelected, RelativeSource={RelativeSource AncestorType={x:Type ext:StyledDataGrid}}, Mode=OneWay}">
<CheckBox.Style>
<Style BasedOn="{StaticResource {x:Type CheckBox}}" TargetType="CheckBox">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ShowCheckBox, RelativeSource={RelativeSource AncestorType={x:Type ext:StyledDataGrid}}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</CheckBox.Style>
</CheckBox>
</Border>
<DataGridColumnHeadersPresenter
x:Name="PART_ColumnHeadersPresenter"