我有一个
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(); }
}
因为计算(总)计数的逻辑应该封装在类中
public int ItemCount
{
get { return YOURCALCULATIONMETHOD(); }
}
有一种方法,但我不确定你想这样做。
我不太擅长 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
}
}