Hi,
I have try to change the text color of the cell with this code, but the cell text remain black.
<Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="BackgroundHover" Value="Red"/> <Setter Property="BorderHoverBrush" Value="#FF4B4B4B"/> <Setter Property="BackgroundAlternate" Value="#FF3F3C3B"/> <Setter Property="BackgroundActive" Value="Orange"/> <Setter Property="ForegroundStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="White" /> </Style> </Setter.Value> </Setter> <Setter Property="ForegroundHoverStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="White" /> </Style> </Setter.Value> </Setter> <Setter Property="ForegroundActiveStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="White" /> </Style> </Setter.Value> </Setter> <Setter Property="ForegroundAlternateStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="White" /> </Style> </Setter.Value> </Setter> <Setter Property="ForegroundSelectedStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="White" /> </Style> </Setter.Value> </Setter> </Style>
The reason the CellValuePresenter.FromCells method returns a null value is because the DataRecordPresenter (and its descendant CellValuePresenters) aren’t created until after the record gets initialized. However, even if that was not the case doing something like this inside InitializeRecord is not a good idea because we only hydrate DataRecordPresenters for records that are in view.
I would like to suggest you the following solution, based on data trigger:
<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="TOTAL" > <Setter Property="Foreground" Value="Red" /> </DataTrigger> </Style.Triggers> </Style></igDP:XamDataGrid.Resources>
Best Regards,Yanko
I am trying to change the Foreground Color on the InitializeRecord event.
I have done :
{
if (dr.Cells[0].Value as string == "TOTAL")
cvp.Foreground = Brushes.Red;
}
The problen is that I get a null value from CellValuePresenter.FromCell(dr.Cells[0]);
dr.Cells[0].Field.Settings.CellValuePresenterStyle = s;
Changes the color on ALL the Column, I we only need on that particular CELL.
Cordially
Ricardo
I would advise you to take a look at the solution, suggested in answer to the question -"How to change the background of a particular cell in the xamDataGrid ( by C# code) ?" .http://forums.infragistics.com/forums/t/14111.aspx
In the xamDataGrid1_SelectedItemsChanged event you should make the following change:CellValuePresenter.FromCell(xamDataGrid1.SelectedItems.Cells[0]).Foreground = Brushes.Orange;
I tried the code and It works for changing the style of the column, what in the case that you only need the change of a particular cell?
Thanks
Thank you very much!