Software design with WPF and MVVM

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am having a bit of a difficulty with the software design of my WPF application. In it, I am having a worker class (ProcessingViewModel) which is currently part of the View. I have bound the properties of the Worker class to some GUI elements and the progress
information is working OK. So no problem with binding here :)
The worker class (ProcessingViewModel) is currently created and maintained in the View (MainWindow).
Now I thought it would be good practice to create and maintain this class in my AppViewModel class where I create and maintain all other application properties. So the design would look something like this:
<img src="http://social.microsoft.com/Forums/getfile/11247/" alt="

...but when I make this move (and expose the relevant properties via properties in AppViewModel) I am suddenly getting errors when I want to set a property of the ProcessingViewModel class (exposed to MainWindow via AppViewModel properties):
<img src="http://social.microsoft.com/Forums/getfile/11250/" alt="
This makes me wonder what I should be doing here as there seem to be a few options to choose from:
1) Not make the refactoring and life with the half-hearted design
2) Use an event based form of messaging to communicate from View to AppViewModel and back
3) Use Dependency Property binding between View-AppViewMode-ProcessViewModel
(if it is possible to bind two CLR objects via DependencyObject ???)

Does anyone have experience with this sort of problem or is able to point me towards a solution? It would be great if I had a sample project (even it was just a mock up).

Cheers Dirk

View the full article
 
Back
Top