开发者

format Header only in xaml datagrid

I have a datagrid and I want to format ONLY the header to be bold but I can't figure out where to put it I tried in the top tag:

<sdk:DataGrid AlternatingRowBackground="LightSteelBlue" 
    AutoGenerateColumns="False" Name="grdSearchResults" 
    RowBackground="Azure" Margin="12,9,12,12" Grid.Row="3" 
    Grid.ColumnSpan="3" FontWeight="SemiBold">         

and the data as well as the header become bold

and i've tried at the column level

<sdk:DataGridTextColumn Binding="{Binding SystemSourceIdentifier}"  
    Header="System Source" Width="Auto" FontWeight="SemiBold" 
    />

which sets the data only bold

this is my full datagrid:

<sdk:DataGrid AlternatingRowBackground="LightSteelBlue" 
        AutoGenerateColumns="False" Name="grdSearchResults" 
        RowBackground="Azure" Margin="12,9,12,12" 
        Grid.Row="3" Grid.ColumnSpan="3" FontWeight="SemiBold">        
    <sdk:DataGrid.Columns>
    <sdk:DataGridTextColumn Binding="{Binding SystemSourceIdentifier}"  
            Header="System Source" Width="Auto" />
    <sdk:DataGridTextColumn Binding="{Binding TableName}" FontSize="11" 
                Header="Key Identifier" Width="Auto" />
        <sdk:DataGridTextColumn Binding="{Binding KeyValue}" FontSize="11" 
                Header="Key Value" Width="Auto" />
        <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" 
                CanUserSort="False" Header="View" IsReadOnly="False" Width="Auto">
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel>
                        <HyperlinkButton Content="..." Name="btnOpen" 
                            NavigateUri="{Binding UrlLink}" 
                            Foreground="#FF000019" 
       开发者_JAVA技巧                     TargetName="_blank" />
                    </StackPanel>
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
        </sdk:DataGridTemplateColumn>
    </sdk:DataGrid.Columns>
</sdk:DataGrid>


Try to add a Style for DataGridColumnHeader like this

<UserControl.Resources>
    <Style x:Key="DataGridColumnHeaderStyle" TargetType="sdk:DataGridColumnHeader">
        <Setter Property="FontWeight" Value="SemiBold"/>
    </Style>
</UserControl.Resources>

And then use the style for your Datagrid

<sdk:DataGrid ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" ...>

Or you can just set the value in the DataGrid ColumnHeaderStyle like this.

<sdk:DataGrid AlternatingRowBackground="LightSteelBlue" AutoGenerateColumns="False" Name="grdSearchResults" RowBackground="Azure" Margin="12,9,12,12" Grid.Row="3" Grid.ColumnSpan="3" FontWeight="SemiBold">
    <sdk:DataGrid.ColumnHeaderStyle>
        <Style TargetType="sdk:DataGridColumnHeader">
            <Setter Property="FontWeight" Value="SemiBold"/>
        </Style>
    </sdk:DataGrid.ColumnHeaderStyle>
    <sdk:DataGrid.Columns>...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜