Introduction to .NET Framework 3.0/Windows Presentation Foundation

Windows Presentation Foundation (codenamed:Avalon) is a new feature (a presentation platform) introduced with .NET Framework 3.0 which supports the creation of documents containing high-resolution pictures and graphics. WPF is also responsible for the integration of pictures and media in ordinary documents. At present, the component performing this function is Windows Forms.

What is Windows Presentation FoundationEdit

A productive, unified approach to UI, media and documents to deliver unmatched user experience

WPF InfrastructureEdit

The Presentation Foundation contains classes to create 'Print' and 'File Open' dialog boxes, script new windows, etc. It makes use of four specific classes most of the time:

  • UIElement
  • FrameworkElement
  • ContentElement
  • FrameworkContentElement

These classes help in building an effective and easy to use user interface. The WPF UI is usually in the form of a Element Tree. Element Trees used in WPF are of two types:

  • Logical Tree
  • Visual Tree

Element Trees are usually implemented in XAML by dragging and dropping and creating relationships between the concerned elements. In code, they depend on how we give property values for properties.

The logical tree involves creating a tree structure by adding a listbox tag and list items inside the tag. In the case of a DockPanel we use Children property.

The visual tree is mainly used by programmers who want to meddle with the underlying low-level components of the program.

Combination of Markup and ProgrammingEdit

While the usage of a programming language as C# is best recommended for programming logic, the usage of markup languages is recommended for texts and UIs.

In earlier versions of the .NET framework, the designer part was separate from the code. However, in .NET 3.0, both the designer part programmed in XAML and the logic programmed in C# are included in the same code.

<Canvas ID="root“ xmlns="“>
	<Button Click="Button_Click">Click Me!</Button>

C# code-behind file 
namespace Button
	public partial class Default : Panel
	{     // Event handler
		   void Button_Click (object sender, System.Windows.Controls.ClickEventArgs e)
 	       {    btn1.Background = System.Windows.Media.Brushes.Red;  }


Windows Presentation Foundation enables the user to create graphic applications of high-quality. You could add existing or create custom buttons using <button> tag, create docked panels, 2D and 3D graphical images, use color picker controls, create or modify images, videos, create custom medi players, etc.

Drawing Object ModelEdit

The WPF graphics system offers a completely new programming style. With Win32-based UI technologies, if you want to draw customized graphics, you must write code that responds to repaint requests, drawing the details on demand. This code effectively paints directly to the screen. If that part of the screen becomes obscured by another window and then uncovered, Windows sends a message requesting that this be redrawn. If you want to change the appearance of your graphics, you need to instruct Windows to invalidate the relevant areas of the screen in order to initiate a repaint.

Richly Formatted TextEdit

WPF also helps us create formatted text easily and hence rich formatting could be used. The contents are enclosed within a <textblock> tag.

User Events could be executed easily by using triggers which are specified using the <trigger> tag. Apart from this, there are many other new innovations in WPF.

Templates and StylesEdit

There are two types of templates: Data Templates and Control Templates. Control Templates define the control and the visual structure of the control.


ControlTemplate x:Key=“MyButton” TargetType=“{x:Type Button}”>
        <Ellipse />
        <ContentPresenter />

On the contrary, data templates contain specifications about the data to be stored.


<DataTemplate DataType=“{x:Type PhotoObject}”>
    <Image Source=“{Binding FileName}” />

Styles are used to specify the syles of buttons used.

<Style x:Key=“MyStyle” TargetType=“{x:Type Button}”>

Styles can also be based on other styles.

Style x:Key=“MyStyle” BasedOn=“{StaticResource BaseStyle}” />
    <Setter Property=“Background” Value=“Green” />


WPF supports three kinds of documents

  • Fixed Documents
  • Flow Documents
  • XPS Documents

WPF has introduced new concepts which make the integration of text with media files easier. WPF also supports a variety of fonts which were not handled by earlier versions.

Fixed DocumentsEdit

Fixed Documents are representative of WYSIWYG ("What you see is what you get") principle. Here, what you see on the screen indicates the actual layout that you will get on paper when the page is printed. Hence, even slight changes to the layout shall be critical.

Flow DocumentsEdit

Flow Documents are those document formats which adjust their size, readability, dimensions, etc. depending on the size of the screen. Documents of this type are also supported by WPF.

XPS DocumentsEdit

XPS documents are those which are exact representations of how the document shall look on paper. They resemble scanned images of the document itself.


  • Ease of Use -- Learn ability, Performance, Reliability, Security, Optimized form factors, Legibility / Readability, Relevance / Contextualization
  • Richness -- Graphics & Media, Data Visualization, Higher Fidelity Information, Globalization, Accessibility, Hardware & Printing Integration.