Hi,
I just want to know how to change the background colour for a particular cell in XamlGrid. I want to do this in Code behind (C#). Could anyone please assist on this.
Many thanks in advance
Florence
I just want to know how to change the background colour for a particular cell on loading the XamGrid itself.
I want to do this in Code behind (C#). Could anyone please assist on this.
Thanks in advance
- Arthi
Hi Arthi,
You can change the background color in two ways.
One by creating a style for the CellValuePresenter of that particular cell or setting the editor's background of the CellValuePresenter to the new color. You can see all the default styles in the local directory on your computer : "~ \Infragistics\NetAdvantage for WPF 2008 Vol. 2\DefaultStyles".
Here is some source code with the Editor's Background.
DataRecord dr = xamDG.ActiveRecord as DataRecord;
CellValuePresenter cvpText = CellValuePresenter.FromRecordAndField(dr, dr.FieldLayout.Fields[0]);
XamTextEditor te = cvpText.Editor as XamTextEditor;
te.Background = Brushes.Red;
Hope this helps.
I have also same problem of changing color of a cell in a particular row. But when I am executing
I am getting cvpText as NULL.
Could you please help?
Regards,
Bijaya
Hello Bijaya,
In which event are you trying to get the CellValuePresenter?
Please note that you will be able to get the CellValuePresenter, or any king of presenter for that matter, only it it is visible and generated.