Manipulating ObservableCollection vs List Replacement

I have a basic dictionary that is used for synchronization (i.e. both for the filetor and for webservice).

At the top of this, I need to create lists / enumerations for use by the WPF interface. What is the difference between connecting an enumerable to a dictionary and calling PropertyChangedit when it is updated to use an ObservableCollection and automatically calls it CollectionChanged.

Synchronization occurs in the background automatically, and some items may be deleted, others may be updated. I want to divulge this information in the WPF interface and to the user smoothly. (i.e. if one item is deleted, the entire screen does not need to be reinitialized). I also want to add animation when items are added and removed (i.e., Fade and Fade) - is this possible if I replace the entire list or does it make every single item disappear again?

So I have to:

1) use the observable collection and write some fantasy synchronization logic between the dictionary and the collection?

2) use linq extension methods to convert the dictionary to enumerated and just call propertychanged in enumerated whenever it changes?

3) synchronize the dictionary and list, replacing the list whenever it is updated?

In addition, how will any of them work with sorting and filtering operations that are performed only for the user interface? (i.e. if I need to filter out some elements from a dictionary based on user selection, should I use a method similar to the one you recommended?)

+3
source share
1 answer

If you “replace” any IEnumerable<T>one when you receive the change, the entire list will be updated in the user interface.

, INotifyCollectionChanged , . , , , .

ObservableCollection<T> . , , , , , SortedDictionary. , , INotifyCollectionChanged .

+3

Source: https://habr.com/ru/post/1734347/


All Articles