ItemsControl ItemsTemplate vs ContentTemplate
- by Allen Ho
Hi,
Is there any difference between setting the ContentTemplate of a ListBoxItem, compared to setting the ItemsTemplate on the ListBox?
Or is it just a preference?
Just say you set the ItemsTemplate of the ListBox can you still get the Data Template you assigned to the ListBox ItemsTemplate via the ListBoxItems ContentTemplate?
ie. Like below
ListBoxItem myListBoxItem = ...;
ContentPresenter myContentPresenter = FindVisualChild(myListBoxItem);
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;