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
No Data
Reply
  • 138253
    Offline posted

    Hello Steve,

     

    I have logged this with development under ID: 142490 and I have also created a support ticket on your behalf: CAS-116452-Y5L5K6 and have linked the development issue to it, so that you can get automatically updated, when a Service Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://ko.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads

     

    You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://ko.infragistics.com/Membership/MySupport.aspx

     

    Meanwhile you can use the sample I attached, where I used Trigger in order to change the Foreground.

    XamDataGridForegroundAlternate.zip
Children