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"/>
</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 TargetType="{x:Type dataPresenter:CellValuePresenter}">
<Setter Property="ForegroundStyle" Value="{StaticResource XamDataGridForegroundStyle}" />
<Setter Property="ForegroundAlternateStyle" Value="{StaticResource XamDataGridAlternateForegroundStyle}" />
</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
For me foreground color on alternating rows working only on mouse over of cell.
I know this is an old thread, but your code does not work on alternating rows.
<Setter Property="Foreground" Value="red" /> works great for the main rows.
Hello,
You can use the sample from one of the previous replies (XamDataGridForegroundAlternate.zip).
Hope this helps.
Hi.
This sample doesn't work. Not change the foreground color.
I use Infragistics 14.2.
Please, Let me know to way to change the foreground color on alternating rows.
Thank you.
Hello Steve,
We have shipped out a new service release where your issue is resolved. I'd be glad to find out if you had tested it out and if it had met your requirements.
You can download the Service Releases by logging to our web site and going to Account \Keys & Downloads.
https://ko.infragistics.com/my-account/keys-and-downloads/