在样式中添加:<Thumb x:Name="PART_RightHeaderGripper" Cursor="SizeWE" HorizontalAlignment="Right" Width="1" Height="25" VerticalAlignment="Center" > <Thumb.BitmapEffect> <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" /> </Thumb.BitmapEffect> </Thumb>
注意:如果x:Name="PART_RightHeaderGripper" 不能用, 试试 x:Name="PART_HeaderGripper" 或 x:Name="PART_LeftHeaderGripper"
例子:XMAL中:
<Style TargetType="DataGridColumnHeader"> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="MinWidth" Value="0" /> <Setter Property="Foreground" Value="#666666" /> <Setter Property="FontSize" Value="12" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Height" Value="25"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DataGridColumnHeader"> <Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1" Background="#FFFFFF" BorderBrush="#CCCACB" Width="Auto"> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <ContentPresenter Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/> <Path x:Name="SortArrow" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Grid.Column="2" Width="8" Height="6" Fill="White" Margin="0,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="1,1" /> <Rectangle Width="1" Fill="#CCCACB" HorizontalAlignment="Right" /> <Thumb x:Name="PART_RightHeaderGripper" Cursor="SizeWE" HorizontalAlignment="Right" Width="1" Height="25" VerticalAlignment="Center" > <Thumb.BitmapEffect> <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" /> </Thumb.BitmapEffect>
</Thumb> </Grid> </Border> </ControlTemplate>
</Setter.Value> </Setter> </Style>