Take the 2-minute tour ×

I have a string value held in a label in an XAML page I am using. When the user opens up a new Silverlight child window, I want to be able to use that string value in the new window. I tried the following-

firstWindow FW = new firstWindow();
string textValue = FW.textBox1.Text;

This does not work however because it is creating a new instance of the firstWindow, where the textbox has no text yet. How can I get the string value after I have opened up the new child window? Thanks in advance.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Create a public property on the Child Window codebehind and set that value in the Parent Window after instantiating and before showing the Child Window.

ChildWindow child = new ChildWindow();
child.PropertyName = this.textBox1.Text;
share|improve this answer
Works exactly as I wanted, thanks. –  Ebikeneser Apr 30 '12 at 16:58

@Chris you are right... Alternatively, you can also set the property in any internal static global variable and retrieve it at any later place.this removes the dependency to create objects and it can be used anywhere in the project

share|improve this answer

Your Answer


