Home Forums WPF controls Xceed DataGrid for WPF How to define Row-Background in code-behind?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24150 |

    Hi there,

    how can i change the background-color of a row in the datagrid in code-behind?
    i already know how to do it via a style but i need to do it in code-behind.

    Thanks for any help,best regards

    b.greber

    Imported from legacy forums. Posted by Benno (had 400 views)

    Xceed Support
    Member
    Post count: 5658

    You could do something like the following:

    <code>
    DependencyObject row = this.OrdersGrid.GetContainerFromItem( this.OrdersGrid.CurrentItem );

    if( row is Xceed.Wpf.DataGrid.DataRow )
    {
    ( ( Xceed.Wpf.DataGrid.DataRow )row ).Background = Brushes.HotPink;
    }
    </code>

    But you have to remember that rows are virtualized, so once they are out of the viewport, they will lose the background color you have set.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 289 views)

    User (Old forums)
    Member
    Post count: 23064

    thanks jenny, thats what im looking for 🙂

    Imported from legacy forums. Posted by Benno (had 3215 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.