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
30
XamDataGrid - Change Alternate Row Foreground
posted

Hi,

I have a data bound XamDataGrid with a custom style. Now I want to use the grid's feature to alternate the row background. I've wrote a custom Style for the DataRecordCellArea where i've set the BackgroundAlternate DependencyProperty. Now my Row Background is alternating. I've also set Foreground Property in this style but it only affects the "non alternating" rows.

How do I set the Foreground Brush of the Alternating Rows? I want it to be the same as the "non alternating" ones.

Parents
No Data
Reply
  • 2500
    Verified Answer
    Offline posted
    Hello Stephan,

     

    Thank you for posting to Infragistics Community.

     

    I have been looking into your question and prepared a small sample with a XamDataGrid with alternate row colors, where the foreground style is also set.

     

    To specify the cells’ foreground color a style, targeting the CellValuePresenter has to be defined, because the CellValuePresenter’s colors are set on top of the DataRecordCellArea’s.

     

    <igWPF:XamDataGrid.Resources>
                    <Style x:Key="CustomForeground">
                        <Setter Property="TextElement.Foreground" Value="red" />
                    </Style>
                    <Style TargetType="{x:Type igWPF:DataRecordCellArea}">
                        <Style.Setters>
                            <Setter Property="Background" Value="AliceBlue" />
                            <Setter Property="BackgroundAlternate" Value="Beige" />
                        </Style.Setters>
                    </Style>
                    <Style TargetType="{x:Type igWPF:CellValuePresenter}">
                        <Setter Property="ForegroundStyle" Value="{StaticResource CustomForeground}" />
                        <Setter Property="ForegroundAlternateStyle" Value="{StaticResource CustomForeground}" />
                    </Style>
                </igWPF:XamDataGrid.Resources>

     

    Attached you will find the sample for your reference. Please, test this suggestion on your side and if you require any further assistance on the matter, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer
Children
No Data