C# Xamarin表单集合视图分页
我想在xamarin表单中实现分页,实际上我还没有为任何移动应用程序实现分页,所以这是我的第一次。我正在使用集合视图和remainingItemThreshold,事件正在被触发,但没有添加项目。我认为这是一个很好的逻辑,但我认为我遗漏了一些东西。提前谢谢C# Xamarin表单集合视图分页,c#,xamarin,xamarin.forms,mobile,uicollectionview,C#,Xamarin,Xamarin.forms,Mobile,Uicollectionview,我想在xamarin表单中实现分页,实际上我还没有为任何移动应用程序实现分页,所以这是我的第一次。我正在使用集合视图和remainingItemThreshold,事件正在被触发,但没有添加项目。我认为这是一个很好的逻辑,但我认为我遗漏了一些东西。提前谢谢 private async void Init() { SetViews(); Methods.SetFlowDirection(this); Methods.Bef
private async void Init()
{
SetViews();
Methods.SetFlowDirection(this);
Methods.BeforeChecking(activityIndicator, parent);
GetOrdersApiResponse response = await OrdersPageLogic.GetOrders();
Methods.AfterChecking(activityIndicator, parent);
//
// get all orders
orders = response.Orders;
toRange = orders.Count >= pagination ? pagination : orders.Count;
// only show first 10 items
ordersToShow = orders.GetRange(0, toRange);
// remove fetched items
orders.RemoveRange(0, toRange);
ordersCollView.ItemsSource = ordersToShow;
ordersCollView.RemainingItemsThreshold = 2;
ordersCollView.RemainingItemsThresholdReached += (s, e) => ordersCollView_RemainingItemsThresholdReached(s, e);
}
private void ordersCollView_RemainingItemsThresholdReached(object s, EventArgs e)
{
int count = 0;
int to = 0;
if (orders.Count == 0)
return;
to = pagination >= orders.Count ? orders.Count : pagination;
foreach(var order in orders.GetRange(0, to))
{
if (count == pagination)
break;
ordersToShow.Add(order);
count++;
}
// remove fetched items
orders.RemoveRange(0, to);
}
所以感谢@Jason,物品来源(在我的例子中是ordersToShow)必须是可观察的集合而不是列表是
ordersToShow
一个可观察的集合
?@Jason该死,我忘了它必须是,我把它定义为一个列表。我会试试看,不过是的,我想它会管用的,我会回去的u@Jason总是拯救我的一天!谢谢你