Getting Started with WPF ? Part1

What is the WPF?

WPF is the window presentation foundation. It is the next generation Presentation system for building window client application with visually good and stunning user experience.
WPF has come with .Net F/W 3.0. WPF contains Vector based rendering engine.

It contains the following features
1 .Has all equivalent common user controls like buttons, check boxes sliders etc.
2 .Fixed and flow format documents
3. Has all of the capabilities of HTML and Flash
4. 2D and 3D vector graphics
5. Animation
6. Multimedia
7. Data binding
8. Style
Using WPF we can create both standalone and browser hosted application

Now let’s start some basic simple application in WPF
Step1: Start Visual Studio 2008/2010/2012,–> select new project –> WPF application

Then you will get the window like this image


WPF application defaults contains the following files as rounded circle shown in the above image
1. Properties
2. References
3. App.xaml
4. MainWindow.xaml

Now lets know what is the use of above files in the project

Properties: It contains all the properties of project. If you want to see then just double click on it. It will look like this image

Using this files, we can change configuration of whole project. It is very important files in the project.

References: This file also available window/web/console/metro type project. It contains all the necessary dll to run the application.We have add .dll and service reference.

App.xaml : It is the application xaml file which contains the resources(style, pens, brushes, etc.) which can be shared in all forms. If you have worked in project then you can consider this like global.aspx. file. It is very handy files for resource sharing in whole application. It contains the information while form should loaded file . You can also changed the first start up file.

In WPF there is no similar concept like to make startup page. We can only do from this file
As shown below the image

app file

Mainwindow.xaml : It is the main form. Here we can design the form as per as our requirement. Any WPF form contains two files i.e Xaml and C# file

Xaml is Extensible application markup language. It is used for designing the form in WPF,Silverlight, Window Phone and Metro application.

Test the Hello program in WPF application
Step 1: Keep one button in Grid panel like this

<Button Name="button" Height="30" Width="200" Click="button_Click">Click Me!

Step 2: Click on click event of button and the write the code in code behind like this

private void button_Click(object sender, RoutedEventArgs e)
MessageBox.Show(“Hello, Window Presentation Foundation”);

Step3: Press the F5 and click on button then you will get output like this