Ответ 1
ItemTemplate предназначен для отображения того, как отображается содержимое вашего элемента данных. Вы используете его для привязки полей данных, форматирования отображаемых строк и т.д. Он определяет способ представления данных.
ItemContainerStyle предназначен для стилизации контейнера элемента данных. В окне списка это будет ListBoxItem. Стилирование здесь влияет на такие вещи, как поведение выбора или цвет фона. Он определяет стиль и UX дисплея.
Страница MSDN для ItemContainerStyle, связанная выше, имеет довольно хороший пример, показывающий некоторые отличия:
<!--Use the ItemTemplate to set a DataTemplate to define the visualization of the data objects. This DataTemplate specifies that each data object appears with the Proriity and TaskName on top of a silver ellipse.--> <ItemsControl.ItemTemplate> <DataTemplate> <DataTemplate.Resources> <Style TargetType="TextBlock"> <Setter Property="FontSize" Value="18"/> <Setter Property="HorizontalAlignment" Value="Center"/> </Style> </DataTemplate.Resources> <Grid> <Ellipse Fill="Silver"/> <StackPanel> <TextBlock Margin="3,3,3,0" Text="{Binding Path=Priority}"/> <TextBlock Margin="3,0,3,7" Text="{Binding Path=TaskName}"/> </StackPanel> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> <!--Use the ItemContainerStyle property to specify the appearance of the element that contains the data. This ItemContainerStyle gives each item container a margin and a width. There is also a trigger that sets a tooltip that shows the description of the data object when the mouse hovers over the item container.--> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Control.Width" Value="100"/> <Setter Property="Control.Margin" Value="5"/> <Style.Triggers> <Trigger Property="Control.IsMouseOver" Value="True"> <Setter Property="Control.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content.Description}"/> </Trigger> </Style.Triggers> </Style> </ItemsControl.ItemContainerStyle>