见下图...
这是使用 QT 在 c++ 中创建的应用程序的屏幕截图。我需要通过将渐变边框添加到我的 DataGrid 标题的外部垂直边缘来创建类似的外观,并且我没有看到允许我完成此操作的 DataGrid 的属性。使用下面的 DataGridColumnHeader 样式,我已经获得了减去外边缘边框后的外观。如何仅将这些边框添加到标题的外部?
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border BorderBrush="{StaticResource ContentPanelHeaderBackgroundBrush}"
BorderThickness="0,1,0,0"
CornerRadius="2,2,0,0">
<DockPanel Background="{StaticResource ContentPanelHeaderBackgroundBrush}" Width="auto">
<Border BorderThickness="0,1,0,0" DockPanel.Dock="Bottom" BorderBrush ="{StaticResource ContentPanelBottomBorderBrush}" />
<Grid Height="22">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter VerticalAlignment="center" Margin="4" />
</Grid>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="4,0,4,0" />
<Setter Property="Foreground" Value="{StaticResource FontActiveBrush}" />
<Setter Property="FontFamily" Value="{StaticResource MainFont}" />
<Setter Property="FontSize" Value="11" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Height" Value="22" />
<Setter Property="Cursor" Value="Hand" />
</Style>