Introduction to WPF and Why WPF, Windows Presentation Foundation

 

WPF(Windows Presentation Foundation) is a new technology that has introduced in the .Net 3.0 Framework for developing of windows based or desktop application. 

The traditional windows technology which is used for developing the desktop applications does not suit for developing the graphics, animations, multimedia, 2D & 3D applications, where WPF fulfil all these requirements.

 

WPF uses the XAML(Extensible Application Markup Language) language to develop the user interface which is derived from XML. XML is used for describing the data and it is platform independent language.

In traditional windows application we use the C# or VB code to create the controls as shown below.

 

            this.button1 = new System.Windows.Forms.Button();

             this.button1.Location = new System.Drawing.Point(392, 176);

             this.button1.Name = "button1";

             this.button1.Size = new System.Drawing.Size(75, 23);

             this.button1.TabIndex = 0;

             this.button1.Text = "Click";

             this.button1.UseVisualStyleBackColor = true;

 

The above code creates the button control in windows application.

 

WPF uses the XAML to create the controls as shown below.

 

<Window x:Class="WpfApplication1.MainWindow"

        xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

        xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

        Title="MainWindow" Height="350" Width="525">

    <Grid>

        <Button Name="btn1" Content="Click" Width="100" Height="50"></Button>

    </Grid>

</Window>

 

The above code creates the button control in WPF application by using XAML.

Generally in traditional windows applications every control is a .Net class, so by creating the object for that class we can create the control and we use the properties to mention control Id, location of the control, text of the control...etc. In WPF we can create the control by using XAML tag as shown above without creating the object and properties are treated as attributes of the tag for providing the Name, Width, Height....etc.

 

The advantage of WPF application is, it id independent of resolution. That means if you develop the application by using WPF it will suit for all resolutions where as traditional windows application will displays differently for each resolution. So that we have to carefully design the UI  to suits for all resolutions while developing the windows applications. If you develop the WPF application you need to bother about resolutions.

 

The disadvantages of Windows based programming are it is not suit for developing the Multimedia desktop applications, it is resolution dependent. The advantages of WPF  are it will suit for developing the multimedia desktop applications and it is resolution independent.