ItemsControl ItemsTemplate vs ContentTemplate

Posted by Allen Ho on Stack Overflow See other posts from Stack Overflow or by Allen Ho
Published on 2010-03-30T01:16:59Z Indexed on 2010/03/30 1:23 UTC
Read the original article Hit count: 627

Filed under:
|
|

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;

© Stack Overflow or respective owner

Related posts about itemscontrol

Related posts about data