I am rewriting my windows forms based application and I am going to use WPF. The application relies heavily on drag and drop techniques, in a very graphically environment. The uses "Design" reports etc. by dragging elements onto a grid, moving them, right click setting properies etc. all of which is saved to a database. Also control program flow by drawing flow charts, with routing and desicion making, all drawn on the form, and again save to a database.
Does MVVM lend itself to this kind of application, or am I trying to fit a round peg in a square hole.
Your thoughts are appriciated.
MVVM lends itself very well to WPF. Can you do drag-drop with WPF and MVVM? Sure you can. Try searching for "WPF Drag Drop Behavior"
My take is to use MVVM, but not religiously.
I mean, use a model to your views, but also use some code behind when needed (drag&drop, double-click). Find a balance that helps your development, without driving you nuts.
There are two really good reasons to go with MVVM:
As several posters have metioned, any eventing related to the UX can be handled in code-behind, but you should be exposing and accessing (read and write) data through your View Models for easy binding in your Views.
As for the extra effort I referred to in #2, you could easily add a static property to your App object to determine if the application is running versus a View being opened in Blend. If the View is open in Blend, leverage mock data instead of making data access calls. Here's some sample code that works for checking if Blend has a View open:
if (Application.Current == null || Application.Current.GetType() == typeof(Application))
{
isInDesignMode = true;
}
else
{
isInDesignMode = false;
}
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With