【发布时间】:2021-03-24 07:01:50
【问题描述】:
我在 iOS 中遇到了这个烦人的问题(在 Android 中工作得非常好),我似乎根本找不到解决方案。有人可以帮我吗?谢谢。
我有标签页,其中有一个消息选项卡,其中包含一个显示用户消息的集合视图。当应用程序启动时,我下载了大约 5 条消息,然后等待剩余的itemthresholdreached 触发,这样我就可以继续获取更多数据,但不幸的是,它没有触发,我被最初的 5 条消息卡住了。
XAML
<CollectionView Grid.Row="1" ItemsSource="{Binding AllMessages, Mode=TwoWay}" x:Name="myMessagesCV" SelectionMode="Single" SelectionChanged="MyMessagesCV_SelectionChanged" RemainingItemsThresholdReached="MyMessagesCV_RemainingItemsThresholdReached" RemainingItemsThreshold="5">
<CollectionView.ItemTemplate>
<DataTemplate>
// Some Code here
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
代码背后
private void MyMessagesCV_RemainingItemsThresholdReached(object sender, EventArgs e)
{
if (IsBusy)
return;
IsBusy = true;
if (!LoadedAllMyMessages)
{
GetMyMessages();
}
if (LoadedAllMyMessages)
{
myMessagesCV.RemainingItemsThreshold = -1;
}
}
请有人救救我。伙计们干杯!
【问题讨论】:
-
我检查了你的代码。
MyMessagesCV_RemainingItemsThresholdReached可以在我这边触发。这是 yoru 参考的示例。 github.com/xamarin/xamarin-forms-samples/tree/master/… 可以在滚动的 IncrementalLoadingPage 中查看。或者你可以使用RemainingItemsThresholdReachedCommand。 -
嘿,Wendy,它现在可以工作了,因为我加载到视图中的项目数量太少而无法触发该事件。因此,增加数量解决了这个问题。谢谢。
-
我在回复中总结了解决方法。你可以接受它作为答案。这将帮助其他人解决同样的问题。谢谢~
标签: xamarin.forms xamarin.android xamarin.ios uicollectionview collectionview