tags:

views:

223

answers:

1

Is it possible to enumerate all the input controls in the codebehind of a silverlight user control?

For example, say you wanted to perform a form submission behind the scenes to another service. You would need to send a POST which included all of the inputs contained on your silverlight page.

+1  A: 

I don't think that there is an automatic way of doing this, but you could always use VisualTreeHelper to traverse the visual tree of your Silverlight app, and pick out the value of any controls that interest you.

However, wouldn't it be easier to just bind the controls to properties on a ViewModel class? You could add a method to the class that would then build the POST request for you, based on the properties that it is managing.

Andy