Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Loop over radio buttons
4 replies. Latest Post by adriaandavel@yahoo.co.uk on July 31, 2009.
(0)
adriaand...
Member
9 points
12 Posts
07-22-2009 2:57 AM |
Hi, I need to loop over radio buttons I have in an ItemsControl that are generated by binding, how would I do that?
meykih
Participant
876 points
211 Posts
07-23-2009 8:49 AM |
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.
07-24-2009 2:06 AM |
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...
All-Star
24929 points
2,425 Posts
07-28-2009 5:07 AM |
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
07-31-2009 12:34 AM |
Hi Jonathan,
Thanks for the info, the VisualTreeHelper works but I seriously dislike it... None the less thanks for the help