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

Binding to an interface is slow

2 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ronald Evers
Top achievements
Rank 1
Ronald Evers asked on 30 Mar 2010, 01:23 PM
Hey all,

I have an issue and I'm not sure what the cause is. I have 2 different Contact object, companies and persons. They both inherit from the interface IContact. So naturally I decided to bind my Gridview to an observableCollection of IContact. This all works fine except that it makes the gridview extremely slow. Whenever I scroll down it takes ages to load the rows. I tried it with just an observablecollection of contactcompany and contactperson and that worked just fine, so the problem only occurs while binding to an interface.
Does anyone know the cause of this? Is there any way to solve this? I created a temporary fix by creating an "in-between" class that has the properties I want to show in the gridview and filling it with both contactcompany and contactperson data, however this solution is less than ideal because it requires a lot of memory and it's really more of a work-around.

If anyone can shed some light on this it'd be great, thanks.

Kind regards

2 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 01 Apr 2010, 06:07 PM
Hello Ronald,

I have tried to replicate your scenario in a separate project, but everything works/fast fine for me. Maybe I'm missing something from your case. Please find my sample project attached. Feel free to modify it to match your scenario exactly.

Regards,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ronald Evers
Top achievements
Rank 1
answered on 06 Apr 2010, 10:59 AM
Thanks for your reply.

I've done some testing and figured out that since the gridview sets a new item every time a new row is loaded. It basically goes through every setter of the properties in the item its bound to. So in my case when its bound to a contactperson it has to set every property. Since the properties have other stuff going on in the setters, like business rule checks, it goes pretty slow when you scroll fast. What I found out is if you bind to an interface then it slows it down to about twice as slow as binding it to a contactperson or contactcompany.

So basically your example won't do me much good as the classes consist out of a single property that's a string, not out of numerous properties that are mostly value objects and have business rule checks in the setters.

I solved the problem by creating a genericrelation class that has only string and int properties, this solves all speed issues but it is still kind of a work around. I doubt you guys can easily fix this, since the same problem occurs in the original Silverlight gridview, so this solution will have to do for now. Thanks for your time.
Tags
GridView
Asked by
Ronald Evers
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Ronald Evers
Top achievements
Rank 1
Share this question
or