Silverlight Question: How can I find the DataTemplate corresponding to an item in a ListBox
Posted
by morpheus
on Stack Overflow
See other posts from Stack Overflow
or by morpheus
Published on 2010-05-08T19:10:17Z
Indexed on
2010/05/08
19:18 UTC
Read the original article
Hit count: 204
Silverlight
|datatemplating
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?
© Stack Overflow or respective owner