Access usercontrol which is hosted within databount ItemsControl
I have created a UserControl (a fairly complex with one various fields and other UI elements) and have databound my view's collection to an ItemsControl. So I have a scrollable set of UserControls arranged nicely on my window, the fields are properly connected to my data, etc., etc. But now...
I need to access one or more of the UserControls directly, rather than through their databinding. All the documentation I can find suggests I do something like the code shown below. (MyUserControl is the class for my UserControl, and ParamControls is the ItemsControl.)
Dim c As MyUserControl
For i As Integer = 0 To ParamControls.Items.Count
sp = CType(ParamControls.ItemContainerGenerator.ContainerFromIndex(i), MyUserControl)
But the call to ItemContainerGenerator.ContainerFromIndex() returns a ContentPresentor rather than an object of MyUserControl. I've been unable to figure out how to use this for anything.
How can I directly access my control?