如何实现IPgedCollectionView接口

问题描述 投票:0回答:2

我有一个

DataPager
,我正在执行自定义分页。我想根据返回的总
ItemCount
DataPager
来设置
COUNT
rows
属性。但我发现
ItemCount
是一个
read-only
属性。我怎样才能
set
呢?有出路吗?

包含

IPagedCollectionView
属性的
ItemCount
接口

public int ItemCount
{
   get { throw new NotImplementedException(); }
}
public int TotalItemCount
{
   get { throw new NotImplementedException(); }
}
c# silverlight interface pagination
2个回答
0
投票

因为计算(总)计数的逻辑应该封装在类中

public int ItemCount
{
   get { return YOURCALCULATIONMETHOD(); }
}

0
投票

有一种方法,但我不确定你想这样做。

我不太擅长 Silverlight,但理论上你需要创建继承自

IPagedCollectionView

的类
public class MyPagedCollectionView : IPagedCollectionView 
{
 public int ItemCount
 {
    get { return this.GetItemCount(); }
 }
 public int TotalItemCount
 {
    get {  return this.GetTotalItemCount(); }
 }

 private int GetTotalItemCount()
 {
     //  Implement the method
 }

 private int GetItemCount()
 {
  //  Implement the method
 }

}
© www.soinside.com 2019 - 2024. All rights reserved.