New Posts New Posts RSS Feed: PagerRepository with DataPager in SL
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

PagerRepository with DataPager in SL

 Post Reply Post Reply
Author
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post Topic: PagerRepository with DataPager in SL
    Posted: 07-Nov-2012 at 3:24am
Is it possible to use PagerRepository with a DataPager?

Thanks.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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.

Edited by mgood - 07-Nov-2012 at 11:00am
Back to Top
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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. 
Back to Top
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post 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?


Edited by cefernan - 08-Nov-2012 at 10:55am
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2012 at 11:29am
Sorry, I only gave you half the information. Your class also has to implement ICollectionView.
 
Back to Top
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2012 at 11:35am
Good!

I was studying exactly this, I'll try. 

Thank you.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down