Chapter 18. WPF Applications

Microsoft currently offers two ways to create desktop applications: Windows Forms (the technology in use since .NET 1.0) and Windows Presentation Foundation, or WPF, introduced in .NET 3.0.

We suggest writing all new applications in WPF. It is a far superior technology and clearly the technology to move forward with. With that said, for supporting existing projects, Windows Forms continues to work side by side with WPF applications, so understanding both is not a bad idea.

In any case, regardless of the technology involved, the C# used is very much the same, so we will cover WPF in this chapter and Windows Forms in the next.

In this chapter, we'll show you how to create a relatively straightforward (though nontrivial) WPF application with C# event handlers. In the next chapter, we'll show you another nontrivial application, written in Windows Forms, and again we'll use C# to implement the event handlers. Everything about the two applications will be different, except for the C#; the language remains unchanged whether you are writing WPF, WinForms, ASP.NET, or Silverlight.

WPF in a Very Small Nutshell

WPF is written, in large part, using a declarative language: XAML (pronounced zamel, to rhyme with camel). XAML stands for eXtensible Application Markup Language, which is a dialect of the industry-standard XML and thus is easily read and manipulated by tools such as Visual Studio.

There is an isomorphic (1:1) relationship between XAML objects and CLR objects, ...

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.