Windows Presentation Foundation Primer
Windows Presentation Foundation (WPF) is the powerful graphical subsystem feature of the .NET 3.5 Framework. It’s preinstalled on Vista and is available for installation on Windows XP SP2 and Windows Server 2003--older versions of Windows cannot run WPF.
WPF Benefits
- The user interface is vastly improved in terms of speed whether or not you use advanced graphics features
- WPF's flexible layout helps build user interfaces that can easily resize and reformat to display dynamic content and multiple languages. It's the end of display resolution problems!
- You can display rich text content anywhere in the user interface including styles, wrapping, and justification
- Unlike Windows Forms, you can easily implement animation, audio and video in your applications
- WPF applications can be deployed on the desktop or hosted in a web browser
- You can easily apply styles and templates to controls and apply these throughout your applications
- Finally makes it possible for a designer to create the look and feel and the developer to implement the behavior
Performance
WPF gets its tremendous power and speed by using DirectX (a hardware-accelerated graphics API commonly used in the gaming community) rather than relying on the "long in the tooth" Windows API. Unlike the extremely limited Windows API, DirectX takes advantage of the processing power of your computer's graphics card by handing off as much processing as possible to the processor on the graphics card (GPU).WPF and Line of Business Applications
Although most WPF samples show graphics-rich, sensational user interfaces, you can still use WPF to create standard Windows applications with conventional look and feel. Even if you miss out on the pizzaz, you still get the benefit of WPF's ability to easily scale to any screen resolution or DPI setting--a near impossiblity with traditional Windows Forms.Choosing Between Windows Forms and Windows Presentation Foundation
If you are starting a new application and you can dictate that users have a newer version of Windows as listed above, then you should definitely use Windows Presentation Foundation. Windows Forms technology isn't going away anytime soon, but Microsoft is putting all of its future Windows UI efforts into WPF. Microsoft has also made it easy to use WPF technology from Windows Forms and vice-versa to help smooth the migration.WPF Assemblies
WPF .NET Framework classes are found in the following assemblies:- PresentationCore
- PresentationFramework
- WindowsBase
WPF and XAML
When you create a WPF window and add controls to it, all information about the window and its controls is stored in XAML (Extensible Application Markup Language) format. This provides an advantage over Windows Forms (which generates C# or VB .NET code behind the scenes for every control and its settings) because it allows true separation of user interface and code. Finally, designers can create the visual portion of your user interface (no code necessary) and developers can add code that implements the behavior of the interface. Designer code is placed in a XAML file and developer code is placed in an associated code-behind file. Typically when using design tools such as Expression Blend and Visual Studio you don't need to know much about the format of XAML.Compiling WPF Applications
When you compile a WPF application it converts the XAML code to Binary Application Markup Language (BAML) which is a far more compressed and tokenized version of XAML that makes run-time processing much faster.If your project contains a window named Window1.xaml, the compiler creates a temporary file named Window1.baml and stores it in your project's obj\Debug folder. It also creates a partial class for the window named Window1.g.cs (g stands for generated) and stores it in the obj\Debug folder too.
If you examine the partial file you'll see it contains a class-level variable (field) for each control on the window. The IntializeComponent() method loads the BAML from the assembly, creating a tree of objects. The Connect() method is called by the BAML parser for each control in the object tree. This method assigns each control object to its corresponding class-level variable and hooks up any event handlers to their associated events.
Dependency Properties
WPF has a special type of property known as dependency properties that provide features such as change notification and property inheritance. They are used for key WPF features such as animation, data binding, and styles.You can easily create a WPF dependency property in VS by using the MM .NET Code Snippet wpfdp.
For more information on dependency properties, check out this link: http://msdn2.microsoft.com/en-us/library/ms752914.aspx
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/18
Comment or report problem with topic
