ObservableCollection not noticing when Item in it changes (even with INotifyPropertyChanged)

前端 未结 18 2708
一生所求
一生所求 2020-11-22 02:06

Does anyone know why this code doesn\'t work:

public class CollectionViewModel : ViewModelBase {  
    public ObservableCollection Con         


        
18条回答
  •  太阳男子
    2020-11-22 02:52

    Here's an extension method for the above solution...

    public static TrulyObservableCollection ToTrulyObservableCollection(this List list)
         where T : INotifyPropertyChanged
    {
        var newList = new TrulyObservableCollection();
    
        if (list != null)
        {
            list.ForEach(o => newList.Add(o));
        }
    
        return newList;
    }  
    

提交回复
热议问题