Please add CachingStrategy="RecycleElementAndDataTemplate"
in the <ListView>
. This issue is related to listview recycle policy. For more details, please see ListView cache data
MAUI: Issue with deleteing the last item from ObservableCollection
I am using an ObservableCollection
saving comments. When I delete a comment, I will fetch the deleted comment id and delete that comment from the ObservableCollection
.
My Problem is if I delete the last comment all the previous comments are vanishing from the UI and showing only the initial comment. When I reopen the page or delete any other comment the vanished previous comments are coming back.
My Code:
foreach (var item in customerCommentList)
{
if (item.parentComment.supportItemComments.commentId == deleteCommentId)
{
customerCommentList.Remove(item);
break;
}
}
Here customerCommentList
is the collection and from that I removing the data. Is there any issue in deleting an item from the collection? Is there any known issue in net 7.0?
Screen recorder video uploaded here and here to understand the issue.
I have created a demo project and added the same logic on it and on demo it is working fine. But on the main project this logic breaks, demo is uploaded here.
Developer technologies | .NET | .NET MAUI
-
Anonymous
2024-04-01T06:54:46.43+00:00