Welcome to the Xceed Community | Help
Community Search  
More Search Options

Row Styling Based on Row Content

Sort Posts: Previous Next
  •  05-02-2012, 3:07 PM Post no. 32068

    Row Styling Based on Row Content

    Hi there,

    I'm sure there's some simple method I'm missing, but here's my problem:

     

    How can I change a row's background color based on the value of data in that row? (E.g. In a grid listing an inventory of parts, change the background of the rows that have 0 parts in stock.)

    It seems relatively easy to do in WPF since you have access to RelativeSource.Self in the style templates, but AFAIK that's not available in Silverlight.

    I'd thought about iterating through the grid manually or harnessing the OnLoadingRow event, but the former is cumbersome and the latter doesn't even seem to be an option for the Xceed DataGrid.

     

    Any help would be appreciated. 

     

    Filed under: , ,
  •  05-09-2012, 9:57 AM Post no. 32088 in reply to 32068

    Re: Row Styling Based on Row Content

    Hi JIbach,

    The DataContext of a DataRow should be the user object. So a quick solution would be to do a Style on DataRow that assignes the Background property to a value that is the result of a Converter.

    You can assign the Style implicitly or use the DataGridControl.RowStyle property.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  05-29-2012, 8:30 PM Post no. 32178 in reply to 32088

    Re: Row Styling Based on Row Content

    Problem solved! I don't know why I didn't think of that before.

     

    Thanks! 

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.