General Checklist of Things to Know When Converting a WPF Application to MVVM

I take the WPF application for vanilla and convert it to use the MVVM pattern. During the code evaluation, I made a list of topics that I needed to know about before converting the application. My list is as follows:

  • xaml dynamic loading (although this is typical of my application)
  • xaml binding to view model commands (buttons, toolbars, menu items)
  • Hotkeys
  • binding of event view model commands (window resizing, mouse events, etc.)
  • processing dialogs (message boxes, file dialogs, user-created dialogs), etc.

I already have different solutions for each element, so I am not asking how to implement them. My real question is: did I miss something? What else is there that I need to know about?

Another way to see this is if I create a WPF WVVM toolkit. What features and functionality are needed for developers to create MVVM applications?

Thanks!

+4
source share
3 answers

I think you have the main problems of MVVM. What else you might need is: "What should I do when my application gets too complicated for MVVM?" This happens rather quickly - it is more than a couple of looks, and you get an explosion of vision models, or you get monolithic viewing models that become bulky and very difficult to maintain.

I would suggest studying the structure of Composite WPF (Prism) as one of the solutions to this problem. Prism is an architectural environment that makes it easy to split applications into modules that are more or less independent of each other. Each module can have a view or two (one of them is probably the most common), and each view can have its own presentation model. He copes with the organization of messaging between modules very poorly. The modules are loaded into the shell window, which you can configure, but you need to.

Hope this helps!

+2
source

You can also configure the infrastructure for some common functions, such as copy / paste buttons, etc.

0
source

The first problem I encountered when switching to MVVM was binding events / routed events to handlers in the virtual machine. There is no built-in or standard method for this. I have a helper to achieve it, but a problem that you might need to consider as an event in the code also hits the MVVM pattern.

0
source

All Articles