简体   繁体   中英

How to bind ConcurrentDictionary with WPF ListView?

I don't have much experience with ListView nor with binding.

I have ConcurrentDictionary

Where the key is long, and Test is a class that has several public attributes.

I want to have a list view with columns showing some of those attributes (no editing is required), and when a user selects an item from the list, can access the corresponding Test object.

I want to make sure also that the operations would be thread-safe as I am using a Concurrent Dictionary where tasks can add items to it at anytime.

I am using .Net Framework 4.5, Visual Studio 2012.

Write value converter for this. On items adding you can just notify whole dict view model (which implements INotifyPropertyChanged ) property changed and list will be repopulated. But you can wrap ConcurrentDictionary in your collection which implements INotifyCollectionChanged . Examples: here and here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM