This commit is contained in:
chfei committed 2026-09-09 15:49:28 +08:00
1 parent 11599bc7d3
commit e12c419ef3
5 files changed
+230 -16

No files matched your search

+80 -11
View File
@@ -11,10 +11,13 @@
<Style x:Key="DefaultCellHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="UseLayoutRounding" 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" />
<Setter Property="BorderThickness" Value="1,0,1,1" />
<Setter Property="Margin" Value="-1,0,0,0" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<!-- 只保留底边框,竖线不再用 Border 画 -->
<Setter Property="HorizontalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=HorizontalContentAlignment}" />
<Setter Property="Padding" Value="8,0" />
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
@@ -28,7 +31,8 @@
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
BorderThickness="{TemplateBinding BorderThickness}"
UseLayoutRounding="True">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ContentPresenter
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
@@ -63,18 +67,52 @@
</Grid>
</Grid>
</Border>
<!-- 关键改动:用固定宽度的 Rectangle 画右侧竖线,永不消失 -->
<Rectangle
Width="1"
HorizontalAlignment="Right"
Fill="{TemplateBinding BorderBrush}"
SnapsToDevicePixels="False" />
<Thumb
x:Name="PART_LeftHeaderGripper"
Width="6"
HorizontalAlignment="Left"
Background="Transparent"
Cursor="SizeWE"
FocusVisualStyle="{x:Null}"
Opacity="0" />
FocusVisualStyle="{x:Null}">
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb>
<Thumb
x:Name="PART_RightHeaderGripper"
Width="6"
HorizontalAlignment="Right"
Background="Transparent"
Cursor="SizeWE"
FocusVisualStyle="{x:Null}"
Opacity="0" />
FocusVisualStyle="{x:Null}">
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="SortDirection" Value="Ascending">
@@ -137,9 +175,25 @@
</Style>
<Style x:Key="DefaultRowHeaderStyle" TargetType="{x:Type DataGridRowHeader}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRowHeader}">
<Border
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextElement.FontSize="10" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DefaultRowStyle" TargetType="{x:Type DataGridRow}">
@@ -184,7 +238,8 @@
<Grid
x:Name="fousIcon"
IsHitTestVisible="False"
Opacity="0">
Opacity="0"
Visibility="Collapsed">
<Path
Width="10"
Height="10"
@@ -290,6 +345,8 @@
</Style>
<Style x:Key="DefaultDataGridStyle" TargetType="DataGrid">
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Background" Value="White" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="ColumnHeaderHeight" Value="36" />
@@ -325,7 +382,8 @@
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
SnapsToDevicePixels="True"
UseLayoutRounding="True">
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
@@ -340,13 +398,24 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border
Grid.Row="0"
Grid.Column="0"
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" />
<DataGridColumnHeadersPresenter
x:Name="PART_ColumnHeadersPresenter"
Grid.Column="1"
Grid.ColumnSpan="2"
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
<Grid Grid.Row="1" Grid.Column="1">
<Grid
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2">
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" />
<Grid
x:Name="NoDataTipsGrid"