What is WPF?

Often we see movies/TV Serious that use software application with extraordinary user interfaces. An example of such a TV serious would be CSI. The first time I saw an episode I was impressed with the software that these guys were using. Controls unfolding, three-dimensional pages spinning, wow these guys are lucky to have such software applications….

Well Guys hold on to your rotating chairs because finally we can do CSI-like UI’s thanks to Microsoft with the mighty WPF.

Windows Presentation Foundation aka Avolon is a major component of .Net Framework 3.0. This technology can be used in two different ways;

In code (like normal Widows Forms)
In XAML (pronounced zammel), HTML like code.

Before WPF one could compare a Designer-Developer relation to a Cat-Dog relation. Reason being the designer dreams of controls that are easy to design with tools as Photoshop yet for the developer to implement these controls, a lot of effort is required. WPF is the answer to every developer’s prayer. Designers now can dream, dream and dream since they will be building the user interface using tools such as Microsoft Expression to generate the XAML for us developers.

Enough with the talk; let’s do some action. We will build a normal button with both C# code and XAML.

C# Code

Button b = new Button();

b.Content = “Hello World”;


< button xmlns=”http://schemas.microsft.com/winfx/2006/xaml/presentation”>
Hello World < /button>

Both of the above code lines will emit the same output i.e. a normal button with the text Hello World. Now lets take this button up a level using one of WPF features; Control Templates.


<ControlTemplate x:Key=“maltaDevButton“ TargetType=“{x:Type Button}“>


<Ellipse x:Name=“outerCircle“ Width=“100“ Height=“100“>


<LinearGradientBrush StartPoint=“0,0“ EndPoint=“0,1“>

<GradientStop Offset=“0“ Color=“Blue“/>

<GradientStop Offset=“1“ Color=“Red“/>





<ContentControl Margin=“10“ Content=“{TemplateBinding Content}“ />




<Trigger Property=“IsMouseOver“ Value=“True“>

<Setter TargetName=“outerCircle“ Property=“Fill“ Value=“Orange“/>






<Button Width=“100“ Height=“100“ FontSize=“10“ Template=“{StaticResource maltaDevButton}“Content=“Malta Dev“ />


Control templates are only one of the features that WPF offers. WPF offers a lot of other things such as

Data Binding
You can bind a control to a collection of data just like in normal windows forms yet with WPF if something in the control changes the UI will update automatically (This is available if the collection is ObservableCollection, or if the Collection being bound implements the INotifyCollectionChange or the INotifyPropertyChange)
You can have animations just like in Macromedia Flash
Rich Content support for all controls
Example: A drop down list that contains images as list items.
Smooth fonts
Since WPF uses vector graphics fonts are not effected when you resize the form.
You can also create you own fonts and embed them in your application as a resource
Full support for documents
Example: You can have a document in a form that flows respectively when the form is resized
Bitmap effects
You can have effects such as blur, shadow, reflection etc on controls.
Integrated video support
You can have a video playing in your form and overlay controls on the video.
Style an application
You can have a predefined style that sets all controls in the application (like CSS for HTML)

The image below is a screen shot of an application developed with WPF. You can download all source code of this application from wpf.netfx.com/files/default.aspx

  1. No trackbacks yet.

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

%d bloggers like this: