Create a C# WPF Application

 

WPF – Windows Presentation foundation is graphical subsystem for rendering user interface. WPF was initially released as a part of .NET Framework 3.0. It relies by the use of DirectX.

WPF employs XAML, an XML-based language which is deployed as standalone desktop programs or hosted as an embedded object in a website. Windows form application, WPF applications can be designed by dragging the controls from the toolbox to design surface. It have a designer, Properties window & the toolbox from which you can design the windows form or application.

Let’s take an example to create a WPF application.

  • Create a WPF application.
  • Toggle between code view and designer view.
  • Change the WPF Window’s properties.
  • Use the XAML editor.
  • Use the controls to fire an event.

Now I will explain you step by step.

  1. Open the visual studio from your system.
  2. Click on new project to create a project.
  3. Go to Windows-WPF application and change the file name like “Hello World WPF”.

1

  1. Go to view menu at the top of window and select toolbox and in left side of window toolbox will appear.
  2. Select any control from toolbox- like select a Button and textbox from toolbox by dragging it in window showing in your window.

2

  1. Select view in menu and click on properties window and it will appear on right side of window.
  2. Change the property of Button and Textbox from properties window by selecting individually-like Height, Width,
  3. After changing the property select on event which is situated just next to property on right side.
  4. Select Button in XAML and create an event by typing “Click”, select it and Select new event handler.
  5. Select Button and do right click and open “View code”. And write code in it – TextBox.Text=”Hello World”.

3

  1. After writing the code press F6 to build the solution.
  2. After your solution is build press F5 to start debugging. New window will open, click on Button and it will show “Hello World” in textbox.

4

So it’s too easy to create a WPF application using C# in visual studio. You can create this by using any control from toolbox and changing its properties and by firing any event from properties.

 

 

 

 

Leave a comment