Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
XamGrid set column background color dynamically based on data
posted

I am new to Silverlight and infragistics, we are in requirement to show background color of the column as red if the data is null for text column or Template columns but we don't know how to make the background color dynamically based on the cell value. the cell value can be text or number.

Thanks in Advance for your help.

kindly contact me if the description is not clear.

  • 6365
    Offline posted

    Hello ,

    In order to change the background color of a cell in the XamGrid whenever it's value is null, you can handle the CellExitedEditMode event of the control by checking the Value of the cell explicitly and setting the Background property of the respective CellContro to Red.


    private void xamGrid_CellExitedEditMode(object sender, CellExitedEditingEventArgs e)
    {
        var cell = e.Cell;

        if (string.IsNullOrEmpty(cell.Value as string))
            cell.Control.Background = new SolidColorBrush(Colors.Red);
        else
            cell.Control.Background = new SolidColorBrush(Colors.Transparent);
    }

    I have attached a sample that demonstrated the behavior from above.

    If you require any further assistance on the matter, please let me know.

    XamGrid_sample.zip