I recently had a requirement to change the background and foreground colour of the rows in a WPF grid based on some criteria specified by the user. This involved showing a dialog following the Mvvm pattern ( I will blog a post on that in due course too). From this dialog the user could select one or more criteria which would be evaluated at runtime to affect the colouring of grid rows.
I'm using the DevExpress grids here but the solution is most likely applicable to many different vendors.
There's few different ways to achieve this but I chose to expose two properties called BackgroundBrush and ForegroundBrush on the row view model. I then use a style to keep the grid in synch with the row view model.
No comments:
Post a Comment