ItemContainerGenerator Class

 

Generates the user interface (UI) on behalf of its host, such as an ItemsControl.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

System.Object
  System.Windows.Controls.ItemContainerGenerator

public sealed class ItemContainerGenerator : IRecyclingItemContainerGenerator, 
	IItemContainerGenerator, IWeakEventListener

NameDescription
System_CAPS_pubpropertyItems

Gets the collection of items that belong to this ItemContainerGenerator.

System_CAPS_pubpropertyStatus

The generation status of the ItemContainerGenerator.

NameDescription
System_CAPS_pubmethodContainerFromIndex(Int32)

Returns the element corresponding to the item at the given index within the ItemCollection.

System_CAPS_pubmethodContainerFromItem(Object)

Returns the UIElement corresponding to the given item.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGenerateBatches()

Returns an object that manages the Status property.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexFromContainer(DependencyObject)

Returns the index to an item that corresponds to the specified, generated UIElement.

System_CAPS_pubmethodIndexFromContainer(DependencyObject, Boolean)

Returns the index to an item that corresponds to the specified, generated UIElement, optionally recursively searching hierarchical items.

System_CAPS_pubmethodItemFromContainer(DependencyObject)

Returns the item that corresponds to the specified, generated UIElement.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventItemsChanged

The ItemsChanged event is raised by a ItemContainerGenerator to inform layouts that the items collection has changed.

System_CAPS_pubeventStatusChanged

The StatusChanged event is raised by a ItemContainerGenerator to inform controls that its status has changed.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.GenerateNext()

Returns the container element used to display the next item.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.GenerateNext(Boolean)

Returns the container element used to display the next item, and whether the container element has been newly generated (realized).

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.GeneratorPositionFromIndex(Int32)

Returns the GeneratorPosition object that maps to the item at the specified index.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel)

Returns the ItemContainerGenerator appropriate for use by the specified panel.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.IndexFromGeneratorPosition(GeneratorPosition)

Returns the index that maps to the specified GeneratorPosition.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.PrepareItemContainer(DependencyObject)

Prepares the specified element as the container for the corresponding item.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.Remove(GeneratorPosition, Int32)

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.RemoveAll()

Removes all generated (realized) items.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.StartAt(GeneratorPosition, GeneratorDirection)

Prepares the generator to generate items, starting at the specified GeneratorPosition, and in the specified GeneratorDirection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIItemContainerGenerator.StartAt(GeneratorPosition, GeneratorDirection, Boolean)

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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIRecyclingItemContainerGenerator.Recycle(GeneratorPosition, Int32)

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIWeakEventListener.ReceiveWeakEvent(Type, Object, EventArgs)

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

ItemContainerGenerator implements IItemContainerGenerator, which is the interface that defines a type which:

  • Maintains an association between the data view of a multiple-item control, such as ContainerFromElement and the corresponding UIElement items.

  • Generates UIElement items on behalf of a multiple-item control.

Each ItemsControl type has a corresponding container type. Container elements are the objects that contain the data items in the item collection. For example, for ListBox, the generated containers are ListBoxItem controls; for ComboBox, they are ComboBoxItem controls.

The ItemsControl generates its items through the IItemContainerGenerator interface. The ItemContainerGenerator property of the ItemsControl is of type ItemContainerGenerator, which implements the IItemContainerGenerator interface. Therefore, you can access the ItemContainerGenerator object associated with your ItemsControl using the ItemContainerGenerator property. 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. 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.

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.

.NET Framework
Available since 3.0
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: