Creating a WPF Example
WPF does a lot of things well, but what sets it apart from previous Windows programming is its command of rich text and rich graphics, and the way things are laid out. This is different from the form-centric model that many of us have (overly?) focused on with Windows Forms.
Tip
Any sweeping generalization about WPF versus Windows Forms is bound to fail, as one can always find a counterexample. What we're describing here is what we've seen in practice in many development organizations, not what can be done in theory. As my old boss, Pat Johnson, used to say: "In theory, theory and practice are the same, but in practice, they never are."
Because this is a book about C# and not WPF, we're going to start by showing you the example we're going to build, and we'll teach only enough to get us there, with an emphasis on the C# needed to make it work.
The Example Program
The example program we're going to use is a variant on an example we've used in a number of other places (varied here to emphasize the C#, to keep you interested, and to stop our editor from yelling at us).
In this example, we're going to reach out to the White House's web site, and pull down the images of the first 20 presidents of the United States and present them in a custom WPF control. The control will not be wide enough to show all 20 images, so we'll provide a horizontal scroll bar, and as the user mouses over an image, we'll provide feedback by enlarging that image (from 75 to 85) and increasing ...
Get Programming C# 3.0, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.