开发者

What is the good way to create MVVM DataPager in Silverlight 4?

I want to use DataPager with MVVM but it's not easy. After I search on internet, there are 2 ways to use DataPager with MVVM in Silverlight.

  1. Introducing An MVVM-Friendly DomainDataSource: The DomainCollectionView (update post for Mix 11)
  2. Architecting Silverlight LOB applications (Part 6) – Building an MVVM Framework

Now I use method #1 but there are some problems with开发者_JAVA技巧 it, for example, i don't know when user change DataPager's page then I can't set BusyIndicator IsBusy to true.

I want to know, what is a good way to use MVVM with DataPager?


The DomainCollectionView, as you mention at #1, is the way I've found.

The DataPager is bound to your DomainCollectionView, so all the user's commands on the pager are passed on. This is being done thru the interfaces that the DomainCollectionView implements, notably IPagedCollectionView, which the DataPager knows how to handle.

Whenever the DataPager needs a new page, it will update the DomainCollectionView, which will in turn call your load function which is setup on the DomainCollectionViewLoader. The article you link gives examples of getting this all set up.

Some place in the setup of the DomainCollectionView, you will create your DomainCollectionViewLoader something like this:

... = new DomainCollectionViewLoader<Customer>(LoadCustomers, OnLoadCustomersCompleted);

In your function LoadCustomers(), you can start showing the BusyIndicator, and when OnLoadCusomtersCompleted() gets hit, you can stop it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜