xamarin.forms - 将记录设置为在 Xamarin 表单中一次显示 10 条记录的列表视图
问题描述
我正在研究 Xamarin 表单。
我有 200 条记录要显示在 listview 上,但我只想加载 10 条记录来显示。当我滚动列表视图时,应该显示接下来的 10 条记录。
有什么解决办法吗?
解决方案
使用您定义的下一个和上一个按钮使用自定义分页。使用 LINQ 获取/跳过每 10 条记录。使用 Label 保存计数并将其 IsVisible 属性设置为 false。
public List<Product> List(int page =1, string category =null)
{
if (category != null) this.CurrentCategory = category;
var products = repository.Products
.Where(p => this.CurrentCategory == null || p.Category == this.CurrentCategory)
.OrderBy(p => p.ProductID)
.Skip((page -1) * PageSize)
.Take(PageSize);
var count = repository.Products
.Where(p => this.CurrentCategory == null || p.Category == this.CurrentCategory).Count();
var resultAsPagedList = products.ToList();
return resultAsPagedList;
}
如果您需要更多信息,请告诉我。
推荐阅读
- xpath - XPath:在子字符串之前/之后提取元素节点
- .net - 我如何让核心控制台捕捉错误
- facebook - 如何为 Facebook 设置图片以在指向 Mediawiki 页面的链接中使用
- javascript - 如何迭代 HTML 数组元素并为每个索引号设置不同的样式?
- python - 如何将文本文件中的函数连接到源代码中的编程函数?
- python - Python Zipfile读取文件并输出每一行而不是文本块?
- python - SQLAlchemy 数据库中的反向引用属性错误
- python - 如何创建可以使用 var 改变自身的代码
- php - Laravel FormRequest 不读取表单数据类型请求
- c# - Create checkboxlist out of data model and store it back in ASP.NET Core MVC