(一)文字居中:
样式文件:<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<SolidColorBrush x:Key="lineColor" Color="#FFFF6500"/>
<!-- Resource dictionary entries should be defined here. -->
<Style x:Key="DataGridHeaderStyle" TargetType="Primitives:DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="FontSize" Value="14.667"/>
<Setter Property="SeparatorBrush" Value="{StaticResource lineColor}"/>
<Setter Property="Background" Value="{StaticResource lineColor}"/>
<Setter Property="BorderBrush" Value="{StaticResource lineColor}"/>
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style x:Key="DataGridCellStyle" TargetType="data:DataGridCell">
<Setter Property="HorizontalContentAlignment" Value="Center" ></Setter>
<Setter Property="FontSize" Value="14.667"/>
</Style>
引用样式:
<local:AutoFillDataGrid AutoGenerateColumns="False" x:Name="DataGrid1&#