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; }
member this.ItemContainerGenerator : System.Windows.Controls.ItemContainerGenerator
Public ReadOnly Property ItemContainerGenerator As ItemContainerGenerator

属性值

与控件关联的 ItemContainerGeneratorThe ItemContainerGenerator that is associated with the control. 默认值为 nullThe default is null.

属性

注解

负责为用户界面 (UI)user interface (UI)ItemsControl主机生成,例如。 ItemContainerGeneratorAn ItemContainerGenerator is responsible for generating the 用户界面 (UI)user interface (UI) for its host, such as an ItemsControl. 它保留控件数据视图中项与相应UIElement对象之间的关联。It 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属性来访问与您ItemsControl的关联的项容器。You can use the ItemContainerGenerator property to access the item container that is associated with your ItemsControl. 例如,如果您有TreeView一个数据绑定控件,并且您希望TreeViewItem基于其索引或其关联数据项获取ItemContainerGenerator.ContainerFromIndex ,则ItemContainerGenerator.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接口还在高级方案中使用。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.

适用于

另请参阅