We want to start develop an intermediate desktop software. We decided to use the WPF. We don't want to use the MVVM pattern. Because we are not familiar with MVVM, and also have time limits. Is it true to develop WPF application without MVVM pattern (using 3 layer architecture but without MVVM) Although does it have better performance than win forms yet ?
-
2WPF applications *are* windows applications, if you mean *win forms* you should write that... – H.B. Jan 14 '12 at 17:16
-
1Nope, WPF is still way slower than WinForms. The design pattern is irrelevant to this. – Cody Gray - on strike Jan 14 '12 at 17:22
-
5without some MVVM help your XAML will became a mess very very fast... – Felice Pollano Jan 14 '12 at 17:23
-
Felice Pollano: i didn't understand,would you please describe more – mahboub_mo Jan 14 '12 at 17:41
-
@FelicePollano Don't confuse binding to a datacontext with MVVM. MVVM requires a separation of View and ViewModel that isn't always needed. – N_A Jan 14 '12 at 19:52
-
@mygogisbox I agree. But from the question I guessed was a not so simple app, that would benefit from MVVM usage. – Felice Pollano Jan 15 '12 at 19:31
-
@FelicePollano I'm assuming you meant me. ;-) Even with a more complicated app there are design patterns which work better than MVVM in certain cases. See my answer below for someone's recommendation to use MVP. See here for another pattern: http://msdn.microsoft.com/en-us/magazine/hh580734.aspx – N_A Jan 17 '12 at 22:33
-
To answer (but this is better fit than a comment) "Although does it have better performance than win forms yet". Yes and not just "yet" probably yes on the day than it was released which is what, 10 years ish ago? It was already tested internally for eons at Microsoft when it was released and when doing anything nontrivial instead of software rendering you're going to be using either built-in features that are GPU accelerated (because WPF is already rendered by DirectX) or writing your own shaders. So performance wise it will perform the same or better for the UI part, the rest is your job. – Ronan Thibaudau Dec 24 '16 at 13:43
5 Answers
You don't need to rely on MVVM when using wpf. Really the keys to using wpf properly are:
- use commands instead of events (you might do this without realizing it, but check to make sure)
- Use data binding instead of getting values off of controls directly
- Set the data context and bind to that instead of binding to the code behind
MVVM works really well for these two things but is not required. Specifically, MVVM requires a 3-tier strict separation of concerns that can just as easily be done with MVP.
As far as performance is concerned, that really depends on the platform on which the app is run and the coding style. If you run it on a computer without a decent graphics card then winForms will probably perform better because wpf will probably revert to software rendering which will be very slow. If you need to do 3d graphics then wpf is really your only option.

- 19,799
- 4
- 52
- 98
-
Actually it's more like: use [commands](http://msdn.microsoft.com/en-us/library/ms752308.aspx) instead of event handling and data binding instead of imperative updating. – H.B. Jan 14 '12 at 23:24
-
@H.B. Commands are good, but they are overkill for most of what I do. Plus data binding replaces some event handling evening if you do everything that isn't data binding through commands. – N_A Jan 14 '12 at 23:51
-
@H.B. Hmmm, I take that back. I use binding WITH routed commands. Not sure why you're contrasting binding and commands. – N_A Jan 15 '12 at 01:37
-
I am not contrasting it, of course you bind commands, but the main functionality of commands is more or less to replace event handling. – H.B. Jan 15 '12 at 02:55
-
This is great answer, and I have to add a couple of notes, MVVM is a simple pattern which has lots of implementations, what which will take time from you is to select and learn how to use a specific implementation of it. But the pattern itself is very simple as @mydogisbox described the concepts here. However what I did was to just copy the RelyCommand or DelegateCommand source from the source codes in internet. – 000 Mar 13 '12 at 06:37
You can develop any application by WinForm and WPF without any Design Pattern or Application Pattern.

- 289
- 3
- 7
You surely do not have to rely on MVVM when using WPF/Silverlight.
As for the performance difference - it could depend on the style of your coding, however if done properly, the difference should not be noticeable.

- 47,367
- 6
- 74
- 106
-
1Agreed, abiding to the MVVM pattern neither automatically leads to a good application architecture (although it helps), nor does not using it prevent you from creating nice applications. There are however a couple of core concepts in WPF that you should get familiar with before you start coding, especially data binding. Get a comprehesive introduction in the [MSDN](http://msdn.microsoft.com/en-us/library/aa970268.aspx). – Clemens Jan 14 '12 at 17:58
MVVM is not required but it solves some common problems with presentation logic. For example, consider the IsBusy ViewModel property. It is set from any operation that has a duration and can be used from Command.CanExecute to signal bound controls to disable themselves when something is running. One property for both logic and UI manipulation. You can think more examples like this that will guide you towards MVVM. It's what the bindings offer that matters, not the pattern it self.

- 109
- 3
There is no requirement to use MVVM. One can use the visual designer to drag n' drop controls onto the design surface. Double click on a button and get an event handler in the code-behind. Let's not forget setting properties & event handlers via the PropertyGrid. All exactly as is done in Winforms.
Without a DataContext data binding doesn't work. If you wish to use databinding, the first examples I've seen set the Window's DataContext = this; in the constructor. In this case the windows acts as its own 'ViewModel'.
You can also use MVVM with View-First. No DI or IoC required.
public class MyViewModel
{
}
public class MyWindow
{
public MyWindow()
{
DataContext = new MyViewModel();
}
}
Of course the next step is implementing DI/IoC using Unity.

- 760
- 4
- 5
-
1You CAN use data binding without setting the `DataContext` property, you just have to specify the relative source (i.e. name the window and reference the window by name). Also, if you're just going to use event handlers like in winforms, then just use winforms. Finally, if you don't have all of M - V - VM separated out then you don't have MVVM, you have something else. – N_A Jan 14 '12 at 23:18