Hi There,
I use xamGrid to display some pnl number and based on value background color of cell should be red or green. I know how to do in XamDataGrid,
=============================
<igDP:XamDataGrid x:Name="_dataGrid" Theme="[Current]">
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout>
<igDP:Field Name="TodaysPnl" Label="TodaysPnl" Width="110" > <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Background" Value="{Binding Path=Cells[TodaysPnl].Value, Converter={StaticResource greaterThanZeroConverter}}"> </Setter> <Setter Property="Foreground" Value="White" /> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
=======================================
I want to do same thing in xamGrid. I don't know how to do it. Does anyone know how can I do it. Here is the code,
<ig:XamGrid x:Name="_dataGrid" AutoGenerateColumns="false" ColumnWidth="*" >
.................
............
<ig:XamGrid.Columns>
<ig:TextColumn Key="TotalTodaysPnl" FormatString="{}{0:C}"> <ig:TextColumn.HeaderTemplate> <DataTemplate> <TextBlock Text="TodaysPnl" /> </DataTemplate> </ig:TextColumn.HeaderTemplate> <!--<ig:TextColumn.CellStyle> <Style> </Setter> </Style> </ig:TextColumn.CellStyle>--> </ig:TextColumn>
</ig:XamGrid.Columns></ig:XamGrid>
Thanking you in advance for your help.
Nasir
I was able to change the style of cell. But now I have a strange issue. Somehow it only changes background color for alternate row.
Here is some code,
======================================================================
<Style x:Key="NegativePnl" TargetType="ig:CellControl" > <Setter Property="FontSize" Value="12"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Foreground" Value="White" /> <Setter Property="Background" Value="Red" /> </Style> <Style x:Key="PositivePnl" TargetType="ig:CellControl" > <Setter Property="FontSize" Value="12"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Foreground" Value="White" /> <Setter Property="Background" Value="Green" /> </Style>
<ig:XamGrid x:Name="_dataGrid" AutoGenerateColumns="false" ColumnWidth="*" CellControlAttached="_dataGrid_CellControlAttached" >
private void _dataGrid_CellControlAttached(object sender, Infragistics.Controls.Grids.CellControlAttachedEventArgs e){ double value = e.Cell.Row.Data as double;
if (null != value) { SetCellStyle(value, e.Cell); }}
private void SetCellStyle(double value, Infragistics.Controls.Grids.Cell currentCell){ if(value < 0) currentCell.Style = Resources["NegativePnl"] as Style; else currentCell.Style = Resources["PositivePnl"] as Style;}
====================================================================
Please let me know if is there anything needs to be done to fix this.
Thanks
Hello Nasir,
I have been looking into your issue and in order to set the background for all rows you can turn off the alternating rows by setting IsAlternateRowsEnabled="False" for the XamGrid.
If you need any further assistance on this matter, feel free to ask.
Yanko,
Thanks for your help. That fixed it. I was looking for incorrect property, AulternateRowsEnabled.
Can you also tell me how can I change Theme property?
Hello,
Thank you for your feedback. If you would like to change the theme of the XamGrid, I can suggest you set its ‘Theme’ property like e.g. :
Theme="IGTheme"
If you have any other questions on this matter, feel free to ask.
I don't see 'Theme' property for xamGrid. But xamDataGrid has 'Theme' property.
Please let me know.
Hi Yanko,
I was able to change the theme from the link provided by you.
Thanks for your help.
I am just checking if you require any further assistance on the matter.
Sorry for my confusion. With my previous post I have shown how to set the ‘Theme’ property of the XamDataGrid. In order to change the theme of the XamGrid I can suggest you look through the following forum thread where this is already discussed :
http://es.infragistics.com/community/forums/p/70715/357896.aspx