English 中文(简体)
MAUI: Issue with abolition of the final items from ObservableCollection
原标题:MAUI: Issue with deleteing the last item from ObservableCollection

我正在使用一种可观测的孔波节储蓄评论。 在我删除评论时,我将引用删除的评论,并从可观察的Collection中删除这一评论。

我的问题是,如果我删除最后一点意见,所有先前的评论都会从“情报调查”中消失,只显示初步意见。 当我重开网页或删除任何其他评论时,过去已消失的评论正回来。

<<>My Code:

foreach (var item in customerCommentList)
{
    if (item.parentComment.supportItemComments.commentId == deleteCommentId)
    {
        customerCommentList.Remove(item);
        break;
    }
}

这里的<代码>customerCommentList是数据收集,从中删除。 在从收集的物品中删除是否有任何问题? 净额7.0中是否有任何已知问题?

屏幕记录器录像带上载here

<>>>>>

我创建了一个更为优化的词汇,得出了更多的结论,并上载了here

在座标上,我增加了2页,其中1页为,另1页为MainPage。 在这两页上,我采用了同样的逻辑,以显示在德国马克的物项,并从德国马克删除一个项目。 http://www.ohchr.org。 页: 1 评论Page 我也面临同样的问题。 在两个网页上,都存在不同之处,因此,我认为这个问题与“倡议”的布局有关。 不幸的是,我可以 trigger开它。

I suspect it is due to calling the functions from background thread, so I verified that and on both background thread and main UI thread the same issue is there.

问题回答

I can reproduce this issue on Android (But work fine on iOS).

The only difference between the CommentPage and the MainPage is the Caching strategy, which is used to improve performance.

该财产的违约价值为<代码>RetainElement。 因此,你只是修改了名单词在<编码>CommentPage中的价值,从而使问题消失。

<ListView
    ...
    CachingStrategy="RecycleElement"
    SeparatorColor="#cecece"
    SelectionMode="None"
    HasUnevenRows="True">

Another suggestion is that you could use CollectionView instead of ListView, as aims to provide a more flexible, and performant alternative to ListView. Tested with no issue on CollectionView.





相关问题
Handling ObservableCollection CollectionChanged Event

I ve seen code like the following in the Silverlight toolkit and can t understand how it is safe to do: private void ItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { ...

Using HashSets with ObservableCollection with WPF

I m using a ListBox to maintain a list of items in a WPF application. The ListBox data source is a HashSet wrapped in an ObservableCollection. ie, I have the following code : this.shackSet = new ...

Opinion wanted: Intercepting changes to lists/collections

Although BindingList<T> and ObservableCollection<T> provide mechanisms to detect list changes, they don t support mechanisms to detect/intercept changes before they happen. I m writing a ...

How to bind a TabControl to an ObservableCollection in XAML

I have the following line of code in my code-behind class. TabControl.ItemsSource = ((MainWindowViewModel)DataContext).TabItemViewModels; I would like to move this to the XAML file. In brief, ...

热门标签