Reputation: 9901
I have subclassed a Silverlight ItemsControl
into a SlideShow
control. This works fine when I hard-code the item elements in the XAML directly. But if I use a DataTemplate
, how do I access the UI elements for each item?
Upvotes: 0
Views: 1258
Reputation: 25116
The ItemsControl may create new items for them as items come and go, so you have to use ItemsControl.Items
to get each data item, then use ItemsControl.ItemContainerGenerator.ContainerFromItem
(or other methods on the ItemContainerGenerator
to find the UI element for that item that was created by the DataTemplate
see: http://msdn.microsoft.com/en-us/library/system.windows.controls.itemcontainergenerator(v=vs.95).aspx
Upvotes: 3
Reputation: 2306
Parse through it with a foreach statement?
eg:
foreach (ChildObject c in ParentObject.Children)
Upvotes: 0