Skip to main content

Microsoft Silverlight

Answered Question Loop over radio buttonsRSS Feed

(0)

adriaandavel@yahoo.co.uk
adriaand...

Member

Member

9 points

12 Posts

Loop over radio buttons

Hi, I need to loop over radio buttons I have in an ItemsControl that are generated by binding, how would I do that?

meykih
meykih

Participant

Participant

876 points

211 Posts

Answered Question

Re: Loop over radio buttons

Generated by binding means you use a datatemplate? And now, what do you want to do? Do you need radiobutton properties (e.g. want to add an eventhandler to each radiobutton)? Or do you need the data you bound to? If last you can use

foreach(object in myItemsControl.Items)

If first you have to create your own control (cause items contain bound data not control). have a look at http://silverlight.net/forums/t/63509.aspx, there a listbox is used but it works the same with an itemscontrol.

Regards,
Maike Ohlig

Please mark post as answer if it helped you

adriaandavel@yahoo.co.uk
adriaand...

Member

Member

9 points

12 Posts

Re: Loop over radio buttons

Hi,

Thanks for the reply. Yes I meant that I use a DataTemplate. I don't need to loop over the data bound to the controls like the Items collection exposes, I need to loop over the actual controls and set properties of the controls...

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

24929 points

2,425 Posts

Microsoft
Answered Question

Re: Loop over radio buttons

Hi Adriaandavel,

If you want to find the controls inside a DataTemplate, we can use VisualTreeHelper.  Please reference to my reply on this thread.

Best regards,

Jonathan

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

adriaandavel@yahoo.co.uk
adriaand...

Member

Member

9 points

12 Posts

Re: Loop over radio buttons

Hi Jonathan,

 Thanks for the info, the VisualTreeHelper works but I seriously dislike it... None the less thanks for the help

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities