Windows Presentation Foundation 4.5 Cookbook
上QQ阅读APP看书,第一时间看更新

Preface

Windows Presentation Foundation has been in release since late 2006, as a part of the then .NET 3.0 Framework, also preinstalled on Windows Vista at the time. It promised to change the way rich client applications are written, and eventually replace the old, Win32-based Windows Forms.

WPF gained traction slowly because of its enormous breadth and the different kind of thinking that was required—using XAML, data binding, templates, and styles was very different from the classic WinForms way of working. The power of WPF was evident, but it was difficult to master, and had a steep learning curve.

Over the years things changed; developers started to get used to and appreciate the new way of doing things. XAML began to look convenient and powerful and not just an extra thing to learn with little benefit. Still, for the newcomer, with or without WinForms experience, WPF looks daunting and uncontrollable.

Patterns have emerged, most notably the Model-View-View Model (MVVM), a variant of other existing view-data separation patterns (MVC and MVP), that made life easier (most of the time) but more importantly set a standard way of interaction of view and data; and although many implementations are possible (this is just a pattern, after all), it does let an application be built in more confidence, piece by piece.

This book holds a set of recipes that show how to do common tasks. But don’t just look at the recipes; instead, look at the other sections to deepen your understanding of WPF. No matter the number of recipes, there will always be other things an application needs that no book can cover; by understanding the foundations well, it’s possible to tackle any problem. This is why I have tried to emphasise the why, and not just the how.

WPF led to a bunch of other technologies being built on similar principles, namely Silverlight (cross browser web client development in .NET), Windows Phone 7.x (Microsoft’s Phone OS that uses a Silverlight variant), and lately Windows 8 and Windows Phone 8—all built around similar concepts such as XAML, dependency properties, templates, styles, and bindings—this shows the power and impact of WPF.