tags:

views:

40

answers:

2

Hello,

I am working on Silverlight project.

I added a custom user control (Say, control1) which has a text box and button to a xaml page (Say, Page1). Now what I want to do is when users clicks on the button, i want to pass the value in the textbox to Page1 and do something.

So basically, I am looking for a way to pass back a value from child to parent page in Silverlight.

Thank you.

+1  A: 

You should look into the Model View ViewModel (MVVM) pattern. It works very well with WPF and Silverlight.

  1. http://en.wikipedia.org/wiki/Model_View_ViewModel
  2. http://karlshifflett.wordpress.com/mvvm/ (lots of good information and demos)

You can do this through binding. Bind the Text value of the TextBox to a string property in your ViewModel and use that property throughout the code.

Aaron Hoffman
A: 

All the controls within your user control are accessible within your main page. If possible, write the click event of the button within the main page and you'll be able to access any control's property. Hope that work for you.

Abhi