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

5 posts, 0 answers
  1. Rob Conley
    Rob Conley avatar
    47 posts
    Member since:
    Sep 2012

    Posted 16 Jan 2013 Link to this post

    I've seen it done a variety of ways, which leaves me confused.

    Does it matter of the collection behind the property supports paging?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jan 2013 Link to this post

    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.

  3. DevCraft banner
  4. Rob Conley
    Rob Conley avatar
    47 posts
    Member since:
    Sep 2012

    Posted 17 Jan 2013 Link to this post

    Thanks for your reply.

    I didn't see anywhere where it essentially said  "it doesn't matter" which way you do it.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jan 2013 Link to this post

    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.

  6. Rob Conley
    Rob Conley avatar
    47 posts
    Member since:
    Sep 2012

    Posted 17 Jan 2013 Link to this post

    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"?
Back to Top
DevCraft banner