Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I'm not even sure that this is possible, but I thought that it would be smart to ask if anyone has ever done it before

I'm writing an interface in WPF using MVVM where an end user will be updating data which is collected using different user controls. The goal is to save all of the updates at the same time with an update button on the main window.

Using a Mediator, I can collect all of the information from all of the controls and then retrieve it for the update, but what would simplify everything is to just take the type that provided all of the data and store updates to IT, and then retrieve it when it's time to move these updates to the database.

I can do THAT with a generic class, but then I have to store the initial class by name to the generic class. What I'd like to do is to store whatever class I decide to use to a generic list. I can envision it, but I've never constructed that sort of relationship before.

I'm I way out to lunch here or is this something someone has done?
Posted

1 solution

If I understand you right, then all you need to do is the properties of an object (in this case the ViewModel) using reflection. You can look at the following for direction:
http://stackoverflow.com/questions/3610891/c-sharp-copying-property-values-from-one-instance-to-another-different-classe[^]
 
Share this answer
 
Comments
Bob Brady 19-Sep-12 16:52pm    
I saw that and I've been coding it today. However I was hoping for a better way
Clifford Nelson 19-Sep-12 17:17pm    
Create an infrastructure, and then you can post an article on Codeproject with the code. Then there will be something better.
Bob Brady 20-Sep-12 8:51am    
In fact, I completely believe that. Genius rises to a challenge, not a question

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