Hi,
I want to change Cells's background to different color.
but I find that when I set the style for Cells, these cells in the alternate row cannot change color as follow chart:
The second cell should be blue, the forth cell should be yellow. But these are also default color.
I change the style in the CellControlAttached event as follow:
private void m_UserManagementGrid_CellControlAttached(object sender, CellControlAttachedEventArgs e) { if (e.Cell.Column.Key == "AccountName" && e.Cell.Value != null) { if (e.Cell.Value.ToString() == "User1" || e.Cell.Value.ToString() == "User2") { Style style = this.Resources["LastMatchStyle"] as Style;//Set Blue Color e.Cell.Style = style; } else { Style style = this.Resources["FirstMatchStyle"] as Style;//Set Yellow Color e.Cell.Style = style; } } }
Could you tell me why the setting cannot work in the alternate row ?
And is there any better method to achieve this function?
You can try the ConditionalFormatting feature of the XamGrid - you can read more about it here - http://help.infragistics.com/NetAdvantage/Silverlight/2010.3/CLR4.0/?page=xamGrid_Conditional_Formatting.html
Also, check this thread - http://community.infragistics.com/forums/p/41733/231650.aspx#231650 - to see how to set a style that changes the background of the alternate row.
Hope this helps