ItemsControl.ItemContainerStyleSelector 属性

定义

获取或设置可应用于每个所生成容器元素的样式的自定义样式选择逻辑。Gets or sets custom style-selection logic for a style that can be applied to each generated container element.

public:
 property System::Windows::Controls::StyleSelector ^ ItemContainerStyleSelector { System::Windows::Controls::StyleSelector ^ get(); void set(System::Windows::Controls::StyleSelector ^ value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.Controls.StyleSelector ItemContainerStyleSelector { get; set; }
member this.ItemContainerStyleSelector : System.Windows.Controls.StyleSelector with get, set
Public Property ItemContainerStyleSelector As StyleSelector

属性值

一个 StyleSelector 对象,其中包含选择要用作 ItemContainerStyle 的样式的逻辑。A StyleSelector object that contains logic that chooses the style to use as the ItemContainerStyle. 默认值为 nullThe default is null.

属性

注解

使用ItemContainerStyle属性设置样式,以影响包含数据项的元素的外观。You use the ItemContainerStyle property to set a style to affect the appearance of the elements that contain the data items. 例如,对于ListBox,生成的容器是ListBoxItem控件; 对于ComboBox,它们是ComboBoxItem控件。For example, for ListBox, the generated containers are ListBoxItem controls; for ComboBox, they are ComboBoxItem controls. 如果定义了多个样式,并且需要提供逻辑来选择要应用的样式,则使用ItemContainerStyleSelector属性而非ItemContainerStyle属性。If you have more than one style defined and need to supply logic to choose which one to apply, then you use the ItemContainerStyleSelector property instead of the ItemContainerStyle property. 请注意,如果ItemContainerStyle设置了属性,则忽略此属性。Note that this property is ignored if the ItemContainerStyle property is set.

为视觉对象自定义提供了极大的灵活性,并提供了许多样式设置和模板化属性。ItemsControlThe ItemsControl provides great flexibility for visual customization and provides many styling and templating properties. 若要影响项的布局,请使用ItemsPanel属性。To affect the layout of the items, use the ItemsPanel property. 如果对控件使用分组,则可以使用GroupStyleGroupStyleSelector属性。If you are using grouping on your control, you can use the GroupStyle or GroupStyleSelector property. 若要指定数据对象的可视化,请使用ItemTemplateItemTemplateSelector属性。To specify the visualization of data objects, use the ItemTemplate or ItemTemplateSelector property. 有关何时指定的ItemTemplate详细信息,请参阅数据模板化概述For more information about when to specify an ItemTemplate, see Data Templating Overview.

依赖项属性信息Dependency Property Information

标识符字段Identifier field ItemContainerStyleSelectorProperty
元数据属性设置为trueMetadata properties set to true NoneNone

适用于