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; }
[<System.ComponentModel.Bindable(true)>]
member this.ItemContainerStyleSelector : System.Windows.Controls.StyleSelector with get, set
Public Property ItemContainerStyleSelector As StyleSelector

屬性值

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. 請注意,如果已設定屬性,則會忽略這個屬性 ItemContainerStyleNote that this property is ignored if the ItemContainerStyle property is set.

ItemsControl提供視覺自訂的絕佳彈性,並提供許多樣式設定和範本化屬性。The 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 None

適用於