I had the opportunity to do a lecture on WPF at my company and realized that people looked like question marks. The problem is Microsoft is introducing a lot of new concepts if Windows Forms used to be your world. Every concept by itself is really simple to understand but for some reason there are few if any blogs that focus on just keeping it simple. I will attempt at this white whale and explain concept for concept in as few lines as possible. So hold on to your socks and be prepared for a really cool paradigm shift in desktop applications. I will dive into detail to every concept and show off code but for now there will only be a brief introduction
WPF introduces a new language for building the interface. It is xml basically but lets you define your controls, design and how the data is presented. If you are used to web development in asp.net this will seem really familiar and if you ask ol’ Microsoft they have borrowed a few concepts from there.
Data Binding is not an unknown concept even for windows forms but it is really simply made once you get the hang of it. Its all about assigning a suitable class to a DataContext property from then on all your public properties and public lists classes etc can be referred to in xaml code.
Now we are talking. Imagine having an object with properties that are hard to understand. Lets say you have the number 10. 10 means nothing by itself but if you state it is the number of items in stock then it has a meaning and a possible visual representation. Wouldn’t it be cool if this number could be showcased as a color or specific control. With converters you can..
MVVM stands for Model – View – View Model and is basically the old Model View Control pattern in fresh clothes and throw in a little observer pattern you are good to go. Most WPF/Silverlight applications built today is MVVM with the blessing of Microsoft. It is imperative to understand the ins and outs of this pattern but you can come a long way of understanding just a little.
The idea with a command is reuse of functionality and also the ability to allow execution of code.