Version

Changing the Column Headers Style

Column headers tend to be one of the most commonly styled elements in a grid.

default xamdatapresenter column headers

The xamDataPresenter’s™ Grid View allows you to style column headers by creating a style that targets the LabelPresenter class. The XAML example code below changes the LabelPresenter’s background and foreground color. This style would be used by all xamDataPresenter instances contained in the element whose resource section this style is placed in. This occurs because there is no Key assigned to the style.

In XAML:

<Style TargetType="{x:Type igDP:LabelPresenter}">
        <Setter Property="Background">
                <Setter.Value>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FF8790AD" Offset="0"/>
                                <GradientStop Color="#FF424759" Offset="0.5"/>
                                <GradientStop Color="#FF505DA3" Offset="0.5"/>
                                <GradientStop Color="#FF2D2DDE" Offset="1"/>
                        </LinearGradientBrush>
                </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="#FFDACA1E"/>
</Style>

By simply placing the above XAML example code inside the Grid.Resources section (see Adding xamDataPresenter to Your Application), you’ll get something similar to the following.

custom styled xamdatapresenter column headers