Silverlight Question: How can I find the DataTemplate corresponding to an item in a ListBox
- by morpheus
I have two classes A & B, and a listbox. I assign listBox.ItemsSource equal to a collection of objects of type A. The listbox items are visualized using silverlight data templating, see http://msdn.microsoft.com/en-us/library/system.windows.datatemplate.aspx and http://www.codeproject.com/KB/WPF/UserControlAsDataTemplate.aspx for example. The listbox.ItemTemplate is a DataTemplate that uses class B to visualize the listbox items. Now, in my code-behind, inside any method of class B, if I do this.DataContext, it points to an object of type A. Thus, given an object of type B, I can find the corresponding object of type A. So far so good. My question is, given an object of type A, how can I navigate to the corresponding object of type B? Is this even possible in SL?