Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a lot of different ObservableCollections. They all have the same number of elements and grow together as new data arrives. They have different properties and I would like to be able to combine them together for use in charting and several datagrids using databinding. Is there an easy way to do this without coping all of the data to a new ObservableCollections. The user will be able to select which ones they want to compare and bring them up.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 11-Dec-12 14:53pm    
Not clear what you want to achieve, exactly? Can you precisely define "combine" you want?
--SA
lyonsjw 12-Dec-12 0:37am    
I have done a lot of studying on this and I believe that I now have a better understanding of what I need and how I should ask the question. Although I have many, for the sake of simplicity I will only refer to 2 classes here as an example. I am gathering data in real time. The data is being processed and placed into ObservableCollection classes. All classes will have the same number of data points. Any class can have many duplicates. The order of the data must not change. I am looking for a way to somehow merge multiple classes together side by side so the resulting class can be used as a single data source with all properties combined when data binding to a WPF chart or datagrid. I would like to do this without have to copy all of the data to the new object, something like a data view. Here’s what I mean by “merge multiple classes together side by side”.
Starting with 2 ObservableCollection classes. The first ObservableCollection is of objects with properties A, B and C and the second ObservableCollection is of objects with properties D and E. I would like to be able to combine them into a single data source of A, B, C, D and E. Hopefully as some kind of data view where the underlining data is accessed but not copied. It seems that CompositeCollection just puts them on top of each other.
Programm3r 12-Dec-12 5:57am    
So why not encapsulate the two classes into one object? You'll have something like class Y with properties A, B, C and class Z with properties D, E. So create a class X with properties which reference class Y and Z. So each new item of Y and Z will be a new 'row' in class X (which will be of type ObservableCollection)
lyonsjw 12-Dec-12 8:59am    
Thanks for your response. I attempted something like that, but abandoned it as I was unable to get the change notifications to flow through the encapsulating class. No matter what I tried the data in the new encapsulating class seemed to be static. It also seemed to be considerably slower than the original classes. If you have a small working example I would be greatly appreciated if you would share it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900