MVVM in a canvas with usercontrols
- by Mauro Destro
I have a MVVM WPF application that basically wants to be a single line diagram designer for an electrical distribution network.
I have a canvas that must contains transformers, circuit breaker, lines and cables.
My big problem is the design... How can i start?
I think about a DesignerView, DesignerViewModel that contains an ObservableCollection of IDesignerItemViewModel that is my base class for all the element. But in this case I have to use ItemsControl to bind the content of the canvas to my collection but the pros is that I don't have to create usercontrol for each element but i'll solve most of the problems with DataTemplate (i suppose).
Each element viewmodel mantain a link to a model persisted in a repository where i mantain my logical tree.
Any hint about how to proceed, I have looked at many DiagramCanvas example but all of those use simple items most like simple rectangle...