where should I save the VM data/instance in a MVVM design?
I'm new to MVVM in a WPF project. As to my understanding, the View is the
objects created by xaml files (window, grid, usercontrol). The Model is my
data. The View-Model is some other object instance.
I have defined all the VM classes, but my questions is where is the best
place to instantiate the VM instance? to be more specific, where should I
declare the VM member variable and call the new() function?
Currently I defined a static member variable of the VM and declare it
inside my usercontrol. The VM should be accessed by several Views and
that's why I declared it as static.
It's kind of ugly, I think, from the Object Oriented design, because I'm
using static or global variables.
So what's the common place to declare VM instances?
No comments:
Post a Comment