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

Create First WPF Application

Article:
Viewed:  1449 
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

1.png

Image 1.

Below is the default structure..

2.png

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

3.png

Image 3.

Output is:

4.png

Image 4.

My XAML code is:

<Window x:Class="MyFirstWPF_APP.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <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" />
    </Grid>
</Window>
 
My XAML.cs code is:

using
System;
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()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBox1.Text = "Welcome to WPF";
        }
    }
}

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