question

damiendarhk-2033 avatar image
0 Votes"
damiendarhk-2033 asked JackJJun-MSFT edited

MVVM approach advice needed

Hello,
I'm a beginner in MVVM, and WPF. My boss asked me to port a winform application in WPF; Basically it have an interface with docked windows (like VS), where each window display some data( loaded from a file) in different way: simple chart, tables, 3d chart, raw data ecc(should be 6 window); this are also interactive, I mean the user can change some value and save the file update for other uses.
I'd like to use mvvm pattern (and caliburn micro framework, or other) to do the task.
My problem is that I'm not sure to have correctly understand how to approach an application like this in MVVM.
For my understanding, I need to use for docking something like avalondock(that support mvvm), and create a View(as usercontrol in VS) and a ViewModel for each dockend"window" plus one as container, and a Model that actually contains the file as an array/stream.
I'm also unsure where handle the "interactivity"(basically the mouse change chart value by mouse), because I founded different answers googleing.
I can add more details if needed . Any advice?

dotnet-csharpwindows-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

MVVM is a huge topic. Personally I think it is far too much to discuss in these forums. There are many, many articles online on how to do it but the best option to me is to read through the documentation and tutorials for the framework you have decided to use. You mention Caliburn so I'd start with their tutorials and documentation. Walk through one of the samples and build it yourself. This will give you an idea of how the framework works, what parts you need and hopefully a solid example from which to base your own application.

After that I'd look to blogs of folks who have tried to use the framework to write more interesting apps, such as:

https://www.cshandler.com/2013/03/basics-of-caliburn-micro-with-simple.html#.YVMskTHMKHs
https://softwareengineering.stackexchange.com/questions/287322/how-to-choose-not-to-use-a-framework-caliburn-micro-etc-in-a-given-mvvm-appl

Bear in mind that this is an art more than science so just because you follow MVVM (or whatever pattern) doesn't mean you have to use it everywhere. In some cases you might find a more direct route might work better either temporarily or long term. It is your app so build it the way it makes the most sense even if it "violates" some arbitrary design pattern rule.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.