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

What's the difference between ElementName binding to DataPager and binding everything to a collection property in MVVM?

4 Answers 62 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Rob Conley
Top achievements
Rank 1
Rob Conley asked on 16 Jan 2013, 11:15 PM
I've seen it done a variety of ways, which leaves me confused.

Does it matter of the collection behind the property supports paging?

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 17 Jan 2013, 09:54 AM
Hi,

You can check more about the ElementName Bindings here. The same is for ElementName binding to a DataPager. Another approach would be to bind everything to a property from your ViewModel using a StaticResource to specify the right Source (as explained here). The difference is that with the first option you rely on the visual element that should be present, with the second option you do not.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rob Conley
Top achievements
Rank 1
answered on 17 Jan 2013, 02:23 PM
Thanks for your reply.

I didn't see anywhere where it essentially said  "it doesn't matter" which way you do it.
0
Dimitrina
Telerik team
answered on 17 Jan 2013, 03:34 PM
Hi,

It does matter.

When you use ElementName Binding, then you should be sure that the visual element will be presented. For example if the element is defined inside a DataTemplate which has still not been loaded, then it will not be available.
On the other hand specifying a Source with a valid StaticResource will always work. That is why I would suggest you that option.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rob Conley
Top achievements
Rank 1
answered on 17 Jan 2013, 07:10 PM
Conceptually, the sources for a Grid and DataPager can be wired up in a serial or parallel fashion. That is, they can both go to the collection, or one can be wired in to the other, with the "other" one then getting wired up to the collection.

When I say it "doesn't matter" I just mean that it appears that it works fine to wire them up either way. It just takes some learning to understand that when looking through the various examples.

Also a bit difficult to wrap my head around is when both the collection and the DataPager can be assigned PageSize properties. Who "wins"?
Tags
DataPager
Asked by
Rob Conley
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rob Conley
Top achievements
Rank 1
Share this question
or