Exploring WPF For Beginners – I

WPF is the most spreading technology these days. When I stepped into this amazing world I found many useful resources all over the web, but for beginner WPF learner like me it’s quite a task to pick the useful stuffs from those. So I go through several resources and try to combine my findings with others. So this post is for those guys who are new on WPF. From this post to next few posts I will explore WPF from basic to more deeper level, So lets begin….

What is WPF:

The Windows Presentation Foundation, WPF, provides a framework a new platform for building rich user experiences on Windows that blend application UI, documents, and media content. WPF offers developers 2D and 3D graphics support, hardware-accelerated effects, interactive data visualization, and superior content readability. WPF uses XAML(Extensible Application Markup Language) for rich user interface development.

A Common Technology for Windows and Web Browser

The primary goal of Windows Presentation Foundation (WPF) is to help developers create attractive and effective user interfaces. WPF unified platform helps make designers active participants in creating user interfaces, and provides a common programming model for standalone and browser applications, a unified platform for modern user interfaces, the ability for developers and designers to work together, and a common technology for Windows and Web browser user interfacesEnabling designers and developers work together like this reduces the translation errors that tend to occur when developers implement interfaces from designer-created images. It can also allow people in these two roles to work in parallel, with quicker iteration and better feedback.

WPF is the platform of choice for today’s visually demanding applications with its inherent support of rich media, data visualization, complex text content, dynamic interactive experiences, and branded or custom look and feel. For these types of applications, WPF provides significant advancements in areas such as advanced layout, control skinning and styling, animated hardware accelerated 2D and 3D graphics, and built in support for rendering of rich documents.

The table shows that prior to WPF building such a rich experience application could require five or more disparate sets of technologies :

WinForms PDF WinForms + GDI Windows Media Player Direct3D WPF
Forms, Controls X X X
Complex text X X
Images X X
Video / Audio X X
2D Graphics X   X
3D Graphics X X

A developer can create a XAML Browser Application (XBAP) using WPF that runs in Internet Explorer. In fact, the same code can be used to create a standalone WPF application and an XBAP.

WPF features

WPF shipped with many stunning features some of them I found interesting :

  • This aims to provide a unified avenue for displaying graphics, as well as more advanced graphical features.
  • Supports 3D model rendering and interaction in 2D applications.
  • Time-based animation. Scene redraws are time triggered
  • Presentation timers are initialized and managed by WPF
  • Animation effects can be defined on a per-object basis, which can be accessed directly from XAML markup
  • WPF has a built-in set of data services to enable application developers to bind and manipulate data within applications.
  • LINQ queries, specifically LINQ to XML, can also act as data sources for data binding
  • Binding of data has no bearing on its presentation. WPF provides data templates to control presentation of data.
  • A set of built-in controls is provided as part of WPF, containing items such as button, menu, grids and list box
  • WPF includes a number of typographic and text rendering features that were not available in GDI.
  • WPF handles texts in Unicode, and handles texts independent of global settings
  • The WPF text engine also supports built-in spell checking. It also supports such features as automatic line spacing, enhanced international text, language-guided line breaking, hyphenation, and justification, bitmap effects, transforms, and text effects such as shadows, blur, glow, rotation etc. Animated text is also supported; this refers to animated glyphs, as well as real-time changes in position, size, color, and opacity of the text.


XAML is the heart of WPF. The benefits of XAML are not just in the presentation, data binding allows declarative connection to the underlying model. All of this makes it much easier to change your user interface without needing to change the other layers of your application. Another important aspect of XAML is the ability through these file formats to have designers and developers able to work on the same files.

WPF and VS2008

Since the platform is new, so is the tooling. Visual Studio 2008 has core WPF support with a new design surface that provides drag and drop support for WPF layout and controls, a new property editor, as well as Intellisense support for XAML editing. Also we can use Microsoft Expression Blend which focuses on the more creative, visual, and interactive aspects of the platform by manipulate animation, skinning and styling, data binding, and general visual asset creation. Expression Blend supports Visual Studio projects.

A Sample Application:

Lets enrich our skills by create a very simple application. I will try to be as much declarative as possible.

From File | New | Project click open the New Project window. Click on Visual C#  and expand its contents. Under .NET 3.5 Framework choose the Windows Application (WPF).

Choose  the name of the application to some name of your choice. For this article I have changed to WPF.Beginer.Part1. Click on the OK button after typing a name of your choice. This creates the necessary file/folders for the application.

There are two XAML files created in the project. The App.xaml and the Windows1.xaml file. App.xaml is more like default application startup point RUN.

Below is the Code of a sample beginner application that will contain a text box, a button and a label. Write something on text box then click button to fire an event handler and write that given text on level that it .pretty simple isn’t it?

Window1.xaml.cs Event Handler:
private void button1_Click(object sender, RoutedEventArgs e){

label2.Content = textBox1.Text;


Run the application thats it our very first WPF application. Have fun.

To be continued…….


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s