Replies: 4 comments 2 replies
-
It's up to you: there's no right or wrong way. The way I would do it is to make a class which is responsible for holding the data, and give the 3 VMs references to this (you can either inject an instance, or make it a singleton - your choice). When one of the VMs changes how the data is visualised, they change some property on this class, and this publishes the change to the other VMs (e.g. through an event), so they can update. |
Beta Was this translation helpful? Give feedback.
-
Thanks, for your advices! |
Beta Was this translation helpful? Give feedback.
-
I'm getting stuck with 2 iusses:
Second iusses is that: I'm learning to use DependencyProperties, and getting exception GetValue and SetValue are not defined because missing inherits of DependencyObject, but I can't inherits it in my viewmodel, because it's already inherits screen, the same in the model because is alread inherits PropertyChangedBase. How can I solve? |
Beta Was this translation helpful? Give feedback.
-
I'm drawing a line chart using something like this code: (I only changed the cycle that create the lines to take them from a list)
Now I would to use it in mvvm, but I'm still struggling to making it work: main problem is "RefreshDraw" where I refere to the usercontrol instance and to mycanvas. How should I do it in mvvm? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm working on an app that have 4 viewmodels(and views): RootViewModel (Window), Chart1ViewModel (usercontrol), Chart2ViewModel (usercontrol), TextViewModel (usercontrol).
The 3 usercontrol are hosted in 3 content controls in the main window.
Whe the app start the main window prompt a OpenFiledialog to load a binary log.
In old winform I put it in a shared array to access it from the 3 usercontrols, but now I'm struggling to make it work in MVVM;
the 3 VM should display the same data but in different way (pie chart,line chart and text), and if the user change something in the "text visualizzation" the other controls should reflect the change.
I done a lot of search on the web, but finding only contradictory answers( use instanse like in winforms, not use, use singleton, not use it etc..) Any advice please?
Beta Was this translation helpful? Give feedback.
All reactions