ItemsControl.ItemContainerGenerator 屬性

定義

取得與控制項關聯的 ItemContainerGeneratorGets the ItemContainerGenerator that is associated with the control.

public:
 property System::Windows::Controls::ItemContainerGenerator ^ ItemContainerGenerator { System::Windows::Controls::ItemContainerGenerator ^ get(); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public System.Windows.Controls.ItemContainerGenerator ItemContainerGenerator { get; }
[<System.ComponentModel.Bindable(false)>]
[<System.ComponentModel.Browsable(false)>]
member this.ItemContainerGenerator : System.Windows.Controls.ItemContainerGenerator
Public ReadOnly Property ItemContainerGenerator As ItemContainerGenerator

屬性值

ItemContainerGenerator

與控制項關聯的 ItemContainerGeneratorThe ItemContainerGenerator that is associated with the control. 預設值為 nullThe default is null.

屬性

備註

ItemContainerGenerator負責產生 使用者介面 (UI)user interface (UI) 其主機的,例如 ItemsControlAn ItemContainerGenerator is responsible for generating the 使用者介面 (UI)user interface (UI) for its host, such as an ItemsControl. 它會維護控制項資料檢視中的專案與對應的物件之間的關聯 UIElementIt maintains the association between the items in the data view of the control and the corresponding UIElement objects. 每個 ItemsControl 都有一個相關聯的專案容器,其中包含專案集合中的資料項目。Every ItemsControl has an associated item container that contains a data item in the item collection. 您可以使用 ItemContainerGenerator 屬性來存取與您的相關聯的專案容器 ItemsControlYou can use the ItemContainerGenerator property to access the item container that is associated with your ItemsControl. 例如,如果您有一個資料繫結控制項, TreeView 而且您想要 TreeViewItem 根據索引或其相關聯的資料項目取得,則可以使用 ItemContainerGenerator.ContainerFromIndexItemContainerGenerator.ContainerFromItem 方法。For example, if you have a data-bound TreeView control and you want to get a TreeViewItem based on its index or its associated data item, you can use the ItemContainerGenerator.ContainerFromIndex or the ItemContainerGenerator.ContainerFromItem method. 或者,您可以使用 ItemContainerGenerator.IndexFromContainer 或方法, ItemContainerGenerator.ItemFromContainer 取得與指定產生的容器專案相關聯的索引或資料項目。Alternatively, you can use the ItemContainerGenerator.IndexFromContainer or the ItemContainerGenerator.ItemFromContainer method to get the index or data item that is associated with a given generated container element.

IItemContainerGenerator介面也用於 advanced 案例中。The IItemContainerGenerator interface is also used in advanced scenarios. 一般而言,具有自己執行虛擬化面板的先進應用程式會呼叫介面的成員。Typically, advanced applications that have their own implementation of a virtualizing panel call members of the interface.

適用於

另請參閱