I have a little issue with the RowLoaded function of the RadGridView :
i use this event to set a binding on a cell, in order to change for example the Background color.
This is working pretty well but, if the targeted column is not visible when the event is raised,
e.Row.Cells doesn't contain it, and even if i scroll to see the column, the event is not re-fired (normal but not convenient).
How should i proceed ?
Note that i search a code related solution, not a xaml solution (like a CellTemplate).
Thanks in advance :)
5 Answers, 1 is accepted
If you are looking for programmatic approach to apply some changes upon changing the value of particular property I believe that CellStyleSelectors are much more appropriate in this case, please refer to the following blog post and online demo:
"Conditional styles and templates with RadGridView for Silverlight and WPF"
the Telerik team
I was using RowLoaded, but recently noticed it doesn't perform well. For example, according to some rule, it changes the background color of the first row, and if you scroll down, that first row goes up, out of view, and a row with different data appears at the bottom, but has the same backround color. How hard would it be for you to create a RowLoaded event which doesn't "break" like this when virtualization is on. (I only suspect that this issue has something to do with that, I'm not sure.)
You do not have to use XAML to work with StyleSelectors - the approach will work for both XAML (MVVM) and code.Regards,
the Telerik team
I am working on a separate component, which resembles a rule engine. I wanted to apply rules to grids using an attached property. The changes to existing code are this way minimal. The only thing required is to define the attached property and the rule engine applies the appropriate rules to the grid.
One issue is that some grids already have style selectors. They will probably be transformed into rules applied through the rule engine, so they aren't a problem. But what if there was a piece of code that I didn't want to put into the rule, something I wanted to keep in code. I imagine I would create a style selector, but not inheriting from StyleSelector base class, but from a new RuleStyleSelector class that I write. There would probably be some control over which code has priority: the custom code or the rule.
Having to apply a style selector in code feels too "fixed". I had hoped to keep this separate from other style-related code.
I'll wait and see if I have to deal with the case when a rowstyleselector is already set on the grid, because it's possible they will all be converted into rules anyway.