To MVVM or not to MVVM, which is a question

I am rewriting a windows form application and I am going to use WPF. The application relies heavily on drag and drop technology in a very graphical environment. Uses Design reports, etc., Dragging items onto the grid, moving them, aligning settings with the right mouse button, etc. All of which are saved in the database. Also control the flow of the program by drawing flowcharts, using routing and creating desicion, all drawn on the form and save it in the database again.

Is MVVM suitable for this kind of application, or am I trying to set the circular snap to a square hole.

Your thoughts are appreciated.

+17
wpf mvvm drag-and-drop
Nov 20 '09 at 14:40
source share
5 answers

My trick is to use MVVM, but not religiously.

I mean, use the model for your views, but if necessary, use some kind of code (drag & drop, double-click). Find a balance that will help your development without driving you crazy.

+24
Nov 20 '09 at 16:50
source share

MVVM has proven itself in WPF. Can you drag with WPF and MVVM? What you can. Try to find "WPD Drag Drop Behavior"

+5
Nov 20 '09 at 14:44
source share

There are two really good reasons for MVVM:

  • It helps you create business logic and data access code that is more easy to test the device.
  • With very little extra effort, all of your UX should be easy to change in Blend.

As noted by several posters, any UX-related event can be handled in code, but you must expose and access (read and write) data through your view models for easy reference to your views.

As for the extra efforts that I mentioned in # 2, you can easily add a static property to your App object to determine if the application is running against a view opened in Blend. If the view is open in Blend, use data from memory instead of making data access calls. Here is an example of code that works to check if Blend is View open:

if (Application.Current == null || Application.Current.GetType() == typeof(Application)) { isInDesignMode = true; } else { isInDesignMode = false; } 

Hope this helps.

+3
Nov 22 '09 at 6:08
source share

If you are looking for a maintianance application and testability in the long run, make sure you can do it with MVVM and WPF. or just go with WPF. The initial MMVM curve is very steep.

+1
Nov 20 '09 at 15:01
source share

Templates like MVVM should make life easier. Therefore, for any occasion, if it seems to you that the template gives you a difficult time, do not hesitate to break it or try something else. Blindly following something will not help. But in any case, MVVM also supports complex user interface interactions such as Drag and Drop, I believe that behavior can help you with this. A google search for WPF drag and drop behavior and you can find a lot of tutorials and code to help you with this.

0
Jul 10 2018-12-12T00:
source share



All Articles