I recently gave a presentation on WPF and Silverlight at this year’s Indy Code Camp. During the talk, I gave a brief overview of View Model. After explaining how data binding works within WPF, I had set myself up for the ultimate punch line:
Since we have this rich data binding model within WPF, why not bind our UI to an object that represents exactly what we want our UI to do.
To demonstrate the power of WPF Data Binding and the View Model pattern I walked through a simple RSS Reader that displayed a list of feeds allowing the user to select one and see a list of feed items and selecting one of those select display the page associated with the feed item in a Frame, all using data binding against a View Model object and zero code behind. While one can argue there are easier ways to create a simple feed reader in WPF…the code was tailored to demonstrate the power of the ViewModel pattern. I saw a number of light bulbs turn on in the audience as a result.