Tuesday, 8 January 2013

Create simple WPF application


Create simple wpf application

Open Visual studio 2010
Click on File menu.. Click on new. Click on Project.. you will get new project pop up window.


Click on Visual C#--> Windows.
Then select WPF Application in side content.



You can also able to change the .Net Framework version.  On the top dropdown list you can see the .Net Framework versions.
To change the project name type what name you want to give.
If you want to change the location click on browser and choose where you want to create the project.
Then click on ok.

You will get WPF application. The screen is look like as below.



In the above screen we can see two windows those are Design and XAML editor window.

Controls are available in toolbox.
Drag button control from toolbox to window.




In XAML Editor Window you can change the properties of controls
In the below screen I change the window Title property as My First Window and Button Content property to Click Me



Double click on Click Me Button, Button Click Event is generated in code file.

The changes in the XAML Editor window you can see the below image.




In code file write the following code to show message.
MessageBox.Show("Welcome to WPF..", "Info", MessageBoxButton.OK);

See image below

















Run the program and in window click on click button you will get message box dialog.  The window is look like below screen.







No comments:

Post a Comment