This is a migrated thread and some comments may be shown as answers.

What is the difference between RowStyle and RowStyleSelector?

0 Answers 17 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
Psyduck asked on 26 Apr 2021, 11:00 AM

Hello.

 

I am trying to change a specific background color of a row in a GridView.

Here, I used rowstyle and RowStyleSelector to see that the color has changed. (Both apply)

 

(My function) Clicking the button checks the GridView Row and changes the background color of only the matching values.

Both work when you up or down the mouse wheel. I think this is not efficient for me.

 

I know that RowStyle uses Convert and RowSelector overrides Style SelectStyle.

Is this just the difference? Or what is the performance efficiency that is good when using my function?

 

Thanks.

Martin Ivanov
Telerik team
commented on 29 Apr 2021, 09:02 AM

I guess by saying that the RowStyle uses Convert, you mean that there is a binding to the Background property of GridViewRow which uses an IValueConverter. Please correct me if I am wrong. 

Both approaches - the IValueConverter one and the StyleSelector - are very similar. Choose whatever you feel more comfortable with.

The StyleSelector is useful when you have several predefined Styles from which you can choose. You can also create styles dynamically in code (in the SelectStyle method). Compared to the IValueConverter, the selector is more convenient when you need to set multiple properties. On the other hand, the IValueConverter is a bit easier to implement, but it may require to implement several converter classes for different properties, which may not be convenient. 

Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
commented on 29 Apr 2021, 11:40 AM

Thanks for the explanation.
In my case, when the button is clicked, when the GridView Item is newly set, the values ​​are compared and the Row Background changes.
I think you say it's up to up.
Then, when I say I use it, I want to know the performance.
I don't need anything else. (For example dynamic)

As mentioned in the above article, Style (IConvert, SelectSyle) is affected when raising or lowering the wheel in GridView.
In other words, Custom Style Class proceeds when scrolling down.
I want to avoid this.
There seems to be a bad effect on my function.

Thanks for any help.
Martin Ivanov
Telerik team
commented on 03 May 2021, 09:14 AM

The performance difference between the Convert() and the SelectStyle() methods should not be noticeable.

The methods are called when you scroll the GridView control because the UI virtualization feature is enabled by default. This feature improves the performance in the control by reusing GridViewRow visual elements and rendering them only in the visible area (the viewport) of the control. This means that on each scroll all styles and properties are re-evaluated in order to match the new data context of the GridViewRow visual. You can avoid this by disabling the UI virtualizaiton, but this will affect the performance highly. 

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
Share this question
or