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
165
how to change cell background colour for specific cells
posted

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

Parents
  • 300
    posted

    Hi Florence,

    i have a Code Behind for highlight a cell when this cell is select :

    if (gridContrat.SelectedItems.Cells.Count > 0)

    {

    foreach (var item in gridContrat.SelectedItems.Cells)

    {

    CellValuePresenter cvp = CellValuePresenter.FromCell(item);if (cvp.Background != Brushes.Yellow)

    {

    cvp.Background =
    Brushes.Yellow;

    }

    else

    {

    cvp.Background =
    Brushes.White;

    }

    }

     

    you must change the "gridContrat.SelectedItems.Cells" by your cell :)

    enjoy

    Nathalie

Reply Children