How to get inputs from dynamically created WPF controls?

I am creating a questionnaire application in WPF. The GUI displaying the questionnaire to the user is built dynamically at runtime through code depending on an XML questionnaire definition. The questions in the questionnaire can be multiple choice questions, yes/no quesitons and free text questions. I create text blocks representing question bodies and then depending on whether the question is multiple choice (I create a set of radio buttons to represent the choices) or yes no (two radio buttons - one for yes and other for no) or free text (text box for collecting user input). My problem is when the user clicks a submit button, I need to collect the answers from the controls and store them back to my object. How do I do this?
Kumara_SanjayaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CuteBugCommented:
I would suggest you make a usercontrol.
The user control will handle multiple choice questions. Depending on how many options are there, add that many radio buttons and set them in one group.
Have a property (say Result) within the user control. each time a radio button is clicked, set the appropriate value of the Result property.

Use this user control to create the Yes No question control.

Using this control, you can save the Result property for the multiple choice or Yes No questions.
0
Kumara_SanjayaAuthor Commented:
I have to do everything in code....I cannot use design time support....is it possible to create a user control without writing any XAML...as I have to write everything as C# code which builds the control dynamically at runtime?

Can you please post a small example...even if very small...just as a guidance for me to start with?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.