I am new to WPF, am developing using C# and .NET3.5. I have a WPFToolkit’s DataGrid added to my window. I am not able to figure out how to set Style to the Column Header and Rows? Rows are added dynamically.
<my:datagrid name="myGrid" xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" itemssource="{Binding }" autogeneratecolumns="False">
SelectionMode="Extended" SelectionUnit="FullRow" CanUserReorderColumns="False"
ColumnHeaderHeight="42" Background="#FFF7F7F7" BorderBrush="Transparent"
HorizontalGridLinesBrush="#FFEAEAEA" VerticalGridLinesBrush="#FFEAEAEA"
HeadersVisibility="Column" RowHeaderWidth="0" HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" ClipboardCopyMode="None" MinRowHeight="28"
Rowremoved="#FFF7F7F7" RowDetailsVisibilityMode="Visible" RowHeight="28"
DataContextChanged="serverGrid_DataContextChanged">
<my:datagrid.columns>
<my:datagridtextcolumn header="Enabled" width="120" binding="{Binding Path=Name}" />
<my:datagridtextcolumn header="Enabled" width="70" binding="{Binding Path=Country}" />
<my:datagridtextcolumn header="Enabled" width="100" binding="{Binding Path=Description}" />
</my:datagrid.columns>
</my:datagrid>
In the Resources have added code for Style :
<!-- DataGridColumnHeader-->
<Style x:Key="ColumnHeaderStyle" TargetType="{x:Type Thumb}">
<setter property="Background" value="#9DCFD0" />
<setter property="FontFamily" value="Arial Rounded MT" />
<setter property="FontSize" value="14" />
<setter property="FontWeight" value="Bold" />
<setter property="Foreground" value="#00545B" />
<setter property="VerticalContentAlignment" value="Center" />
<setter property="HorizontalContentAlignment" value="Center" />
</Style>
In TargetType of Style, am not able to set as my:DataGridColumnHeader or just DataGridColumnHeader. It says “… not found”. In my:DataGridTextColumn I guess HeaderStyle is the property to set the style. But am able to define Style for the same.
Also how to set style for Rows added dynamically? Where am I going wrong?
Any help is highly appreciated.
you can do like this:
First is the namespace to header:
then this is style: