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”;

XAML

< button xmlns=”http://schemas.microsft.com/winfx/2006/xaml/presentation”&gt;
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.

 

<Window.Resources>

<ControlTemplatex:Key=maltaDevButtonTargetType={x:Type Button}>

<Grid>

<Ellipsex:Name=outerCircleWidth=100Height=100>

<Ellipse.Fill>

<LinearGradientBrushStartPoint=0,0EndPoint=0,1>

<GradientStopOffset=0Color=Blue/>

<GradientStopOffset=1Color=Red/>

</LinearGradientBrush>

</Ellipse.Fill>

</Ellipse>

<Viewbox>

<ContentControlMargin=10Content={TemplateBinding Content} />

</Viewbox>

</Grid>

<ControlTemplate.Triggers>

<TriggerProperty=IsMouseOverValue=True>

<SetterTargetName=outerCircleProperty=FillValue=Orange/>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

</Window.Resources>

<Grid>

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

</Grid>

wpf button

Yes guys. This is a real button not an image!

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)
  • Animations
    • 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

Healt care app

Excited? In this article we didn’t even touch the surface of WPF. Download .net 3.0 from http://www.netfx3.com and enjoy…..

>> I would also suggest to take this intro for WPF
http://joshsmithonwpf.wordpress.com/a-guided-tour-of-wpf/

13 thoughts on “What is WPF?

  1. Hello
    I want to make a presentation that I should explain about tools of VB.NET
    Can you give me information as soon as possible
    Thank you
    Best Regards
    Mahmood

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s