Hello, On Android platform, right?
It is calling around 6 items before the last item.
I still cannot reproduce this issue. The event be triggered once when sliding to 50, and it will be triggered again when loading more hands to 60.
But at that time, the
CollectionView
is scroll to the first item.
In the UserTweetsList
method of DashBoardViewModel
, the model is added to Items, but you set the new ObservableCollection
to the Items
and AllItems
. Please do not set a new object after adding item and add models to AllItems
directly.
// Items = new ObservableCollection<UserTweetsList>(Items.Distinct());
// AllItems = new ObservableCollection<UserTweetsList>(Items);
And you can refer to the following code:
// new the ObservableCollection for AllItems
// Constructor
public DashBoardViewModel()
{
AllItems = new ObservableCollection<UserTweetsList>(Items);
}
Adding model
public async void UserTweetsList()
{
try
{
if (!loadMore)
{// add model to AllItems
AllItems.Add(new UserTweetsList() { tweetData = "message 1", tweetUser = "Albert" });
AllItems.Add(new UserTweetsList() { tweetData = "message 2", tweetUser = "Albert" });
...
AllItems.Add(new UserTweetsList() { tweetData = "message 49", tweetUser = "Albert" });
AllItems.Add(new UserTweetsList() { tweetData = "message 50", tweetUser = "Albert" });
}
else
{
AllItems.Add(new UserTweetsList() { tweetData = "message 51", tweetUser = "Albert" });
...
AllItems.Add(new UserTweetsList() { tweetData = "message 60", tweetUser = "Albert" });
}
// Items = new ObservableCollection<UserTweetsList>(Items.Distinct());
// AllItems = new ObservableCollection<UserTweetsList>(Items);
Debug.WriteLine("itemCount:>>" + AllItems.Count);
if (AllItems.Count == 0)
{
ComingSoonVisibility = true;
chatVisibility = false;
}
else
{
ComingSoonVisibility = false;
chatVisibility = true;
}
isLoading = false;
if (AllItems.Count != 50)
{
haveItemsToLoad = false;
}
else
{
haveItemsToLoad = true;
}
}
catch (Exception e)
{
Debug.WriteLine(e.ToString());
}
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.