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 also fall across a similar problem with you, it puzzled me for several days.
But now I figured it out !!
It is quite easily to do this.
You can just set RecordContainerGenerationMode to PreLoad in XamDataGrid !!
here is for you reference:http://forums.infragistics.com/forums/p/29380/128390.aspx
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.
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 Arthi,
I will attach a project that does almost the same thing. I color the borders of cells like you, but in 3 different colors depending on the value of the cell.
Hope it would be helpful to you.
Alex.
This is my grid, here, i want to shoe red border for null value field. When i try to scroll down / up the borders are misplaced. for ex. 1001 - Age cell was bordered red, but when in scroll dow and up the redborder is coming in 1002 - age cell.Can you please help me in this regard?