Print Page | Close Window

PagerRepository with DataPager in SL

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3771
Printed Date: 26-Apr-2024 at 6:22am


Topic: PagerRepository with DataPager in SL
Posted By: cefernan
Subject: PagerRepository with DataPager in SL
Date Posted: 07-Nov-2012 at 3:24am
Is it possible to use PagerRepository with a DataPager?

Thanks.



Replies:
Posted By: mgood
Date Posted: 07-Nov-2012 at 8:40am
Yes, it is. You simply write your own IPageCollectionView adapter to wrap the IPager<T> you get from the PagerRepository.

http://msdn.microsoft.com/en-us/library/system.componentmodel.ipagedcollectionview%28v=vs.95%29.aspx -


Posted By: cefernan
Date Posted: 07-Nov-2012 at 11:58am
You mean that I have to create a class implementing IPagedCollectionView, and the IPager<T> must be used inside this class to create my collection. 

    public class PagedItems<T> : IPagedCollectionView
    {
        private IPager<T> _pager;
        ...
        // IPagedCollectionView members ...
    }

Is this it?


Posted By: mgood
Date Posted: 07-Nov-2012 at 12:13pm
Yes, that's correct. Your class will translate calls to IPagedCollectionView members to the corresponding member on the nested IPager<T>. It's a straight forward adapter as the two interfaces are very similar. 


Posted By: cefernan
Date Posted: 08-Nov-2012 at 10:53am
Marcel,

There is something not so clear to me. My class will be just a implementation of IPagedCollectionView, so I won't have a list of results, just couple properties and methods redirecting to the related in IPager. Where will I use page.Results (from Page<T>) in my class?


Posted By: mgood
Date Posted: 08-Nov-2012 at 11:29am
Sorry, I only gave you half the information. Your class also has to implement ICollectionView.
 
http://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionview%28v=vs.95%29.aspx -


Posted By: cefernan
Date Posted: 08-Nov-2012 at 11:35am
Good!

I was studying exactly this, I'll try. 

Thank you.


Posted By: mgood
Date Posted: 08-Nov-2012 at 11:42am
Great. Since you only asked me about the DataPager I only gave you that part. To be clear, IPagedCollectionView is used by the DataPager to page your collection. ICollectionView is used by the control that displays the collection. They are technically two different things.
 
Alternatively, you can simply expose the current page as a property of your class and then bind the control to it. ICollectionView gives you the notion of a current record. You may not need that, or you could implement that in the view model. It's a lot simpler than implementing all the members of ICollectionView.



Print Page | Close Window