Column Header Styling Issue in Data Grid in WPF
Posted
by sbrakl
on Stack Overflow
See other posts from Stack Overflow
or by sbrakl
Published on 2009-05-11T11:05:53Z
Indexed on
2010/05/21
15:30 UTC
Read the original article
Hit count: 213
I have formated the Wcf Toolkit Datagrid and below in the is the ColumnHeader Style for it But, there are still some area in Column Header, which are not styled as shown in the image
http://www.freeimagehosting.net/uploads/9aba4fbd93.jpg
<Style x:Key="ColumnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Orange" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="dg:DataGridColumnHeader">
<dg:DataGridHeaderBorder
x:Name="headerBorder"
Background="Orange">
<Border BorderThickness="2"
CornerRadius="5"
Background="Orange"
BorderBrush="DarkOrange">
<Grid>
<TextBlock Text="{TemplateBinding Content}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"/>
</Grid>
</Border>
</dg:DataGridHeaderBorder>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<dg:DataGrid Grid.Row="1" Grid.RowSpan="1"
Name="dgQuestion"
HorizontalAlignment="Left"
AutoGenerateColumns="True"
Width="740"
MinWidth="200"
MaxWidth="740"
Background="Wheat"
ColumnHeaderHeight="30"
ColumnHeaderStyle="{DynamicResource ColumnHeaderStyle}"
RowStyle="{StaticResource RowStyle}"
CanUserAddRows="False"
CanUserDeleteRows="False"
AlternationCount="2"/>
© Stack Overflow or respective owner