From Windows Forms to WPF with MVVM
This talk illustrates how Windows Presentation Foundation can dramatically improve the experience of developers, not just designers. Two versions of a simple application will be demonstrated, one developed using Windows Forms, and one using the same approach in WPF. By showing the same application in both technologies, we will show how a short learning curve can be used to migrate development to WPF.
I’ll then discuss three new features of WPF: Data Binding, Templating, and Commanding. I’ll show how they enable a new application architecture, the Model-View-ViewModel pattern, and illustrate how rethinking our approach to design in terms of these three features allows for huge gains in flexibility, testability, and maintainability of our applications.
Finally, we’ll look at third version of our application, a rewrite of our previous application using the Model-View-ViewModel pattern.
This talk is approximately 1 hour and 15 minutes in length.
Presentation Material:
Slides:Â Windows Forms to WPF with MVVM
Hello Reed,
Please let me know where can I find the link to this talk “From Windows Forms to WPF with MVVM”? I have read through the series and it helped me in understanding the basics of WPF-MVVM as a newbie.
Best regards.
Kate,
Unfortunately, the talk hasn’t recorded for rebroadcast. The slides and source are here, and the series covers all of the basic content, however. There is a talk I did that’s very similar you can watch here:
http://events.boostweb20.com/Events/SeattleCodeCamp2010/#state=sessionCode%242003-6
-Reed
That link seems not to be active anymore.
Hi,
I have been looking for some good code/article targeted to WinForms programmers and found that the sample code (WPFWithMVVM) was excellent. But, I have a couple of questions:
(1) In the MainView.xaml, the ListBox’s DataTemplate directly uses the model class – i.e., Animal. The bindings are set between the view and model. Does this violate the spirit that views should know nothing about models?
(2) Could you tell me how I can separate out the DataTemplate portion of the MainView.xaml to a separate xaml file?
I have just started learning WPF+MVVM. I’d appreciate it if you’d find some time to respond back to the questions.
Thank you very much for the sample code.
Thanks for the questions! I’ll try to answer the best I can.
1) This really depends on your approach. I personally see it as a layered model, where nothing should ever look “up”, but you can look down as much as you want. As such, I don’t have a problem with the View binding to the Model, it’s more making sure the Model/VM doesn’t see the View. There are other people who disagree on this point, but I find that practicality outweighs purity in this respect, and it’s often just far simpler to use the Model directly than force a dev to make a “ViewModel wrapper” that’s pure boilerplate code.
2) You could use a merged resource dictionary to do this. See: http://msdn.microsoft.com/en-us/library/aa350178(v=vs.110).aspx
-Reed
Hi Reed,
Thanks for the response! I decided to follow your advice – “higher layers can look down”. I have been doing “MVP-VM” on WinForms, based on my past article (http://www.codeproject.com/Articles/88390/MVP-VM-Model-View-Presenter-ViewModel-with-Data-Bi), but I decided now is the time to switch to WPF+MVVM, even if DirectX and 3D has nothing to do with my desktop apps. I also really like your coding style with StyleCop in mind. I have been using it with ReSharper and can’t code a line without them.
Thanks again and have a nice weekend.
Tetsu