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.

Send Value From One Page To Another Page in WPF

Viewed:  6088 
Posted On:  03/10/2012 19:01:02 
In this article I am going to show how we can send any value from one form to another form in WPF 

In this article I am going to show how we can send value from one window to other window in WPF.

Below is my Window1.xaml code.

<Window x:Class="SendValueFromAnotherPageInWPF.Window1"    xmlns=""
    xmlns:x=""    Title="Window1" Height="300" Width="300">
        <Button Content="Submit" Height="23" Margin="87,89,116,0" Name="SubmitBtn" VerticalAlignment="Top" Click="SubmitBtn_Click" />
        <TextBox Height="23" Margin="30,46,43,0" Name="textBox1" VerticalAlignment="Top" />
        <Label Content="Enter your name here" Height="28" HorizontalAlignment="Left" Margin="26,12,0,0" Name="label1" VerticalAlignment="Top" />

Window1.XAML.cs code.

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 SendValueFromAnotherPageInWPF

    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>

    public partial class Window1 : Window
        public Window1()

        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
            Window2 mySeconPage = new Window2();
            mySeconPage.TextBlockName.Text = textBox1.Text;

Now this is my Window2.xaml code

<Window x:Class="SendValueFromAnotherPageInWPF.Window2"    xmlns=""
    Title="Window2" Height="300" Width="300">
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" x:Name="WelcomeHeading" Text="Welcome:" VerticalAlignment="Top" FontSize="17" FontStretch="ExtraCondensed"/>

   <TextBlock Height="23" HorizontalAlignment="Left" Margin="90,10,0,0" x:Name="TextBlockName" VerticalAlignment="Top" FontSize="15" FontStretch="ExtraCondensed" />


 When Run the application.


Image 1.


Image 2.

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