Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Change the Foreground colour on alternating rows
posted

Hi,

I have what I think is a fairly simple scenario.  Instead of having the Background colour alternating on my rows I would like to keep this constant and have the Foreground style change instead.  All the existing posts I've read seem to focus on Background and it appears that Foreground isn't working in the same way.

With the following xaml all my rows look the same, am I doing something wrong?

<Window x:Class="Infragistics.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:dataPresenter="http://infragistics.com/DataPresenter"

        Title="MainWindow"

        Height="350" Width="525">

    <Window.Resources>

        <SolidColorBrush x:Key="DefaultBackground" Color="#FF3D3C3C" />

        <SolidColorBrush x:Key="DefaultForeground" Color="Ivory" />

 

        <Style x:Key="XamDataGridForegroundStyle" TargetType="{x:Type ContentPresenter}">

            <Setter Property="TextBlock.Foreground" Value="{StaticResource DefaultForeground}"/>

        </Style>

 

        <Style x:Key="XamDataGridAlternateForegroundStyle" TargetType="{x:Type ContentPresenter}">

            <Setter Property="TextBlock.Foreground" Value="Red"/>

            <Setter Property="TextBlock.FontStyle" Value="Italic"/>

        </Style>

    </Window.Resources>

 

    <Grid Background="{StaticResource DefaultBackground}">

 

        <dataPresenter:XamDataGrid DataSource="{Binding People}"

                                   Background="{StaticResource DefaultBackground}">

            <dataPresenter:XamDataGrid.Resources>

                <Style TargetType="{x:Type dataPresenter:DataRecordCellArea}">

                    <Setter Property="Background" Value="{StaticResource DefaultBackground}" />

                    <Setter Property="BackgroundAlternate" Value="{StaticResource DefaultBackground}" />

                </Style>

 

                <Style TargetType="{x:Type dataPresenter:CellValuePresenter}">

                    <Setter Property="ForegroundStyle" Value="{StaticResource XamDataGridForegroundStyle}" />

                    <Setter Property="ForegroundAlternateStyle" Value="{StaticResource XamDataGridAlternateForegroundStyle}" />

                </Style>

            </dataPresenter:XamDataGrid.Resources>

 

            <dataPresenter:XamDataGrid.FieldSettings>

                <dataPresenter:FieldSettings />

            </dataPresenter:XamDataGrid.FieldSettings>

 

            <dataPresenter:XamDataGrid.FieldLayoutSettings>

                <dataPresenter:FieldLayoutSettings HighlightAlternateRecords="True" />

            </dataPresenter:XamDataGrid.FieldLayoutSettings>

        </dataPresenter:XamDataGrid>

    </Grid>

</Window>

 

Thanks,

Steve

Parents Reply Children