ItemContainerGenerator 类

定义

代表主机主机生成用户界面 (UI),例如 ItemsControlGenerates the user interface (UI) on behalf of its host, such as an ItemsControl.

public ref class ItemContainerGenerator sealed : System::Windows::Controls::Primitives::IRecyclingItemContainerGenerator, System::Windows::IWeakEventListener
public sealed class ItemContainerGenerator : System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator, System.Windows.IWeakEventListener
type ItemContainerGenerator = class
    interface IRecyclingItemContainerGenerator
    interface IItemContainerGenerator
    interface IWeakEventListener
Public NotInheritable Class ItemContainerGenerator
Implements IRecyclingItemContainerGenerator, IWeakEventListener
继承
ItemContainerGenerator
实现

注解

ItemContainerGenerator实现IItemContainerGenerator,它是用于定义类型的接口:ItemContainerGenerator implements IItemContainerGenerator, which is the interface that defines a type which:

ItemsControl个类型都有一个对应的容器类型。Each ItemsControl type has a corresponding container type. 容器元素是包含项集合中数据项的对象。Container elements are the objects that contain the data items in the item collection. 例如,对于ListBox,生成的容器是ListBoxItem控件; 对于ComboBox,它们是ComboBoxItem控件。For example, for ListBox, the generated containers are ListBoxItem controls; for ComboBox, they are ComboBoxItem controls.

ItemsControl 通过IItemContainerGenerator接口生成其项。The ItemsControl generates its items through the IItemContainerGenerator interface. ItemContainerGenerator 属性ItemsControl的类型ItemContainerGenerator为,它实现接口。IItemContainerGeneratorThe ItemContainerGenerator property of the ItemsControl is of type ItemContainerGenerator, which implements the IItemContainerGenerator interface. 因此,你可以ItemContainerGenerator ItemsControl使用ItemContainerGenerator属性访问与关联的对象。Therefore, you can access the ItemContainerGenerator object associated with your ItemsControl using the ItemContainerGenerator property. 例如,如果你有一个数据TreeView绑定,并且希望基于其索引或其关联的TreeViewItem数据项获取ItemContainerGenerator.ContainerFromIndex ,则ItemContainerGenerator.ContainerFromItem可以使用或方法。For example, if you have a data-bound TreeView, 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 associated with a given generated container element.

除了这些用法以外, IItemContainerGenerator接口在高级方案中使用。Apart from those usages, the IItemContainerGenerator interface is used in advanced scenarios. 通常,具有其自己的虚拟化面板实现的高级应用程序会调用接口的成员。Typically, advanced applications that have their own implementation of a virtualizing panel call members of the interface.

属性

Items

获取属于此 ItemContainerGenerator 的项的集合。Gets the collection of items that belong to this ItemContainerGenerator.

Status

ItemContainerGenerator 的生成状态。The generation status of the ItemContainerGenerator.

方法

ContainerFromIndex(Int32)

返回对应于 ItemCollection 中给定索引处的项的元素。Returns the element corresponding to the item at the given index within the ItemCollection.

ContainerFromItem(Object)

返回对应于指定项的 UIElementReturns the UIElement corresponding to the given item.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GenerateBatches()

返回可托管 Status 属性的对象。Returns an object that manages the Status property.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IndexFromContainer(DependencyObject)

返回对应于指定生成的 UIElement 的项的索引。Returns the index to an item that corresponds to the specified, generated UIElement.

IndexFromContainer(DependencyObject, Boolean)

返回对应于指定生成的 UIElement 的项的索引,选择性递归搜索分层项。Returns the index to an item that corresponds to the specified, generated UIElement, optionally recursively searching hierarchical items.

ItemFromContainer(DependencyObject)

返回对应于指定生成的 UIElement 的项。Returns the item that corresponds to the specified, generated UIElement.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

事件

ItemsChanged

ItemsChanged 事件由 ItemContainerGenerator 引发,以通知项集合已更改的布局。The ItemsChanged event is raised by a ItemContainerGenerator to inform layouts that the items collection has changed.

StatusChanged

StatusChanged 事件由 ItemContainerGenerator 引发,以通知控件其状态已更改。The StatusChanged event is raised by a ItemContainerGenerator to inform controls that its status has changed.

显式界面实现

IItemContainerGenerator.GenerateNext()

返回用于显示下一项的容器元素。Returns the container element used to display the next item.

IItemContainerGenerator.GenerateNext(Boolean)

返回用于显示下一项的容器元素,并返回其是否为新生成(实现)的容器元素。Returns the container element used to display the next item, and whether the container element has been newly generated (realized).

IItemContainerGenerator.GeneratorPositionFromIndex(Int32)

返回映射到指定索引处的项的 GeneratorPosition 对象。Returns the GeneratorPosition object that maps to the item at the specified index.

IItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel)

返回适合由指定面板使用的 ItemContainerGenerator。Returns the ItemContainerGenerator appropriate for use by the specified panel.

IItemContainerGenerator.IndexFromGeneratorPosition(GeneratorPosition)

返回映射到指定 GeneratorPosition 的索引。Returns the index that maps to the specified GeneratorPosition.

IItemContainerGenerator.PrepareItemContainer(DependencyObject)

准备指定元素作为相应项的容器。Prepares the specified element as the container for the corresponding item.

IItemContainerGenerator.Remove(GeneratorPosition, Int32)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

IItemContainerGenerator.RemoveAll()

移除所有生成(实现)项。Removes all generated (realized) items.

IItemContainerGenerator.StartAt(GeneratorPosition, GeneratorDirection)

从指定的 GeneratorPosition 开始并在指定的 GeneratorDirection 内准备生成器以生成项。Prepares the generator to generate items, starting at the specified GeneratorPosition, and in the specified GeneratorDirection.

IItemContainerGenerator.StartAt(GeneratorPosition, GeneratorDirection, Boolean)

从指定的 GeneratorPosition 开始并在指定的 GeneratorDirection 内控制是否从生成(实现)项开始来准备生成器以生成项。Prepares the generator to generate items, starting at the specified GeneratorPosition, and in the specified GeneratorDirection, and controlling whether or not to start at a generated (realized) item.

IRecyclingItemContainerGenerator.Recycle(GeneratorPosition, Int32)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

IWeakEventListener.ReceiveWeakEvent(Type, Object, EventArgs)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

适用于

另请参阅