Aracılığıyla paylaş


DataGridColumn.HeaderStyle Özellik

Tanım

Sütun üst bilgisini işlerken kullanılan stili alır veya ayarlar.

public:
 property System::Windows::Style ^ HeaderStyle { System::Windows::Style ^ get(); void set(System::Windows::Style ^ value); };
public System.Windows.Style HeaderStyle { get; set; }
member this.HeaderStyle : System.Windows.Style with get, set
Public Property HeaderStyle As Style

Özellik Değeri

Sütun üst bilgisini işlemek için kullanılan stil; veya nullayarını kullanmak ColumnHeaderStyle için kullanın. Kayıtlı varsayılan değerdir null. Değeri nelerin etkilediği hakkında bilgi için bkz DependencyProperty. .

Örnekler

Aşağıdaki örnek, içindeki sütun başlıklarının DataGridstilini değiştirmek için bir stil kaynağı kullanır. İlk sütun başlığının stili, öğesini geçersiz kılan DataGrid.ColumnHeaderStylebir satır içi stille ayarlanır.

<Window.Resources>
    <!-- DataGrid style -->
    <Style x:Key="DataGridStyle1" TargetType="{x:Type DataGrid}">
        <Setter Property="ColumnHeaderStyle" Value="{DynamicResource ColumnHeaderStyle1}"/>
    </Style>
    <!-- DataGridColumnHeader style -->
    <Style x:Key="ColumnHeaderStyle1" TargetType="DataGridColumnHeader">
        <Setter Property="Height" Value="30"/>
        <Setter Property="Background" Value="LightBlue"/>
        <Setter Property="Foreground" Value="Blue"/>
        <Setter Property="FontSize" Value="18" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="ToolTip" Value="Click to sort."/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
<Grid>
    <DataGrid Name="dataGrid1" Margin="12,12,0,0" 
              AutoGenerateColumns="False"
              Style="{DynamicResource DataGridStyle1}">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Name" 
                                Binding="{Binding Name}">
                <!-- Local Style for header of first DataGrid column. -->
                <DataGridColumn.HeaderStyle>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Background" Value="Blue"/>
                        <Setter Property="Foreground" Value="White"/>
                        <Setter Property="FontSize" Value="24"/>
                    </Style>
                </DataGridColumn.HeaderStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Class"
                                Binding="{Binding Classification}" />
            <DataGridCheckBoxColumn Header="Extinct"
                                    Binding="{Binding Extinct}"/>
        </DataGrid.Columns>
    </DataGrid>
</Grid>

Açıklamalar

Sütun başlığı için bir Style tanımlamak için değerini belirtin TargetTypeDataGridColumnHeader.

tüm Style sütun üst bilgilerine veya tek bir sütun üst bilgisine uygulanabilir. Tek bir üst bilgisine uygulamak Style için özelliğini ayarlayın DataGridColumn.HeaderStyle ; bu özellik özelliğinden DataGrid.ColumnHeaderStyle önceliklidir.

Şunlara uygulanır

Ayrıca bkz.