Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

Create First WPF Application

Viewed:  2559 
Posted On:  01/06/2013 09:09:56 
How to create a simple WPF application ? How to learn WPF step by step ? 

HI All, I am very new to write article. So I choose WPF to write. This is my first application in WPF. This is a simple application in which I am showing how we can start to play with WPF.

Open Visual Studio -> New -> Project -> Select WPF Application


Image 1.

Below is the default structure..


Image 2.

Now I am going to use a TextBox and Button in this application. On click of button I am showing a text in text box.

Drag and drop button and text box from tool box


Image 3.

Output is:


Image 4.

My XAML code is:

<Window x:Class="MyFirstWPF_APP.Window1"
    Title="Window1" Height="300" Width="300">
        <Button Margin="102,122,102,117" Name="button1" Click="button1_Click">Click Me</Button>
        <TextBox Height="23" Margin="23,51,33,0" Name="textBox1" VerticalAlignment="Top" />
My XAML.cs code is:

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MyFirstWPF_APP
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
        public Window1()
        private void button1_Click(object sender, RoutedEventArgs e)
            textBox1.Text = "Welcome to WPF";

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us