Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Sending any value from one form to another form in WPF
Posted by
Purushottam Rathore
in
Blogs
|
WPF with C#
on
Sep 15, 2010
How to send any value from one form to another form in WPF?
Tweet
7611
2
0
Suppose I want to send some values from one form to another form in wpf application, then what to do?
In my application i have two window forms name as
Test.xaml
and
Welcome.xaml
like as follows:
Test.xaml
<
Window
x
:
Class
="Login_WPF.Test"
mlns
=
http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:
x
=
http://schemas.microsoft.com/winfx/2006/xaml
Title
="Test"
Height
="300"
Width
="300">
<
Grid
>
<
Button
Content
="Submit"
Height
="23"
HorizontalAlignment
="Left"
Margin
="30,0,0,150"
Name
="Ok"
VerticalAlignment
="Bottom"
Width
="75"
Click
="Ok_Click" />
<
TextBox
Height
="23"
HorizontalAlignment
="Left"
Margin
="30,46,0,0"
Name
="textBox1"
VerticalAlignment
="Top"
Width
="120" />
<
Label
Content
="Enter your name here"
Height
="28"
HorizontalAlignment
="Left"
Margin
="26,12,0,0"
Name
="label1"
VerticalAlignment
="Top" />
</
Grid
>
</
Window
>
Welcome.xaml:
<
Window
x
:
Class
="Login_WPF.Welcome"
xmlns
=
http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:
x
=
http://schemas.microsoft.com/winfx/2006/xaml
Title
="Welcome"
Height
="300"
Width
="350">
<
Grid
>
<
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" />
</
Grid
>
</
Window
>
My first page is Test.xaml. write the following lines of code on button's click event as follows:
Test.xaml.cs:
using
System;
sing
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.Shapes;
namespace
Login_WPF
{
///
<summary>
///
Interaction logic for Test.xaml
///
</summary>
public
partial
class
Test
:
Window
{
public
Test()
{
InitializeComponent();
}
private
void
Ok_Click(
object
sender,
RoutedEventArgs
e)
{
Welcome
objWelcome =
new
Welcome
();
objWelcome.TextBlockName.Text = textBox1.Text;
objWelcome.Show();
//Sending value from one form to another form.
Close();
}
}
}
Output:
Figure 1:
Enter the input in to text box and click on Submit button value will show on next page as follows:
Figure 2:
share this blog :
Get Days using Enum in WPF
What is WPF?
Related Blogs
WPF: Namespaces needed to host WPF control in Windows form application
WPF: Logical and Visual Trees
File attachments in Mail in WPF
Get Days using Enum in WPF
WPF-Set Background color.
WPF: Styles and Templates
post comment
Good one.................
Posted by
Jamil Akhtar
on
Feb 02, 2012
Good one.................
Posted by
Jamil Akhtar
on
Feb 02, 2012
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Email Validation in wpf
Most popular video formats
Benefits and limitations of using Cookies
Sending any value from one form to another form in WPF
Count the maximum length of textbox using Javascript
Difference between Sql server 2005 and 2008
Keep in mind while using Ajax Updatepanel.
PopUp window using JavaScript in asp.net
Serial number in Gridview or datalist in asp.net
What is Index in sql server? It's purpose?
View All
Latest Blogs
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
JQuery Maxchars Plugin
View All
Sponsored by
Become a Sponsor