I am working on graph editor using WPF and I would like to know how I can design this system with help MVVM pattern.
There 3 parts:
-
Model:
class Graph with 2 properties:public List States and public List and Add/Edit/Remove States/Transitions methods -
ViewModel
class GraphVM with 2 properties:public List States and public List and Add/Edit/Remove States/Transitions methods - View
Is it a good approach or should I implement separete VMs for States and Transitions?
Whilst it depends on the exact functionality in your UI, I would suggest that VMs for each states and transitions would be a good idea regardless. Generally you’ll find yourself needing them sooner or later, so you may as well just create them up-front. The alternative is for your view to bind directly to your model, which not only creates a tight coupling that may be difficult and time-consuming to break later, it also inhibits your ability to add UI-specific behaviors on top of them (such as selection and drag+drop).