【问题标题】:CollecionView RemainingItemThresholdReached is not firing when Tabbed Pages are initialized in Xamarin iOS在 Xamarin iOS 中初始化选项卡式页面时,CollecionView RemainingItemThresholdReached 未触发
【发布时间】: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


【解决方案1】:

RemainingItemsThresholdReached 可以被足够的项目触发。

您可以在 Scrolling 的 IncrementalLoadingPage 中查看。或者你可以使用RemainingItemsThresholdReachedCommand

这里是 yoru 参考的例子。 https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/CollectionViewDemos

【讨论】:

    猜你喜欢
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-17
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多