Item​Container​Generator Item​Container​Generator Item​Container​Generator Class

Definition

Provides mappings between the items of an ItemsControl and their container elements.

public sealed class ItemContainerGenerator : IItemContainerGeneratorpublic sealed class ItemContainerGenerator : IItemContainerGeneratorPublic NotInheritable Class ItemContainerGenerator Implements IItemContainerGenerator
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

You set an ItemContainerGenerator as the value of the ItemsControl.ItemContainerGenerator property.

Methods

ContainerFromIndex(Int32) ContainerFromIndex(Int32) ContainerFromIndex(Int32)

Note

ContainerFromIndex may be altered or unavailable for releases after Windows 8.1. Instead, use ItemsControl.ContainerFromIndex.

Returns the container for the item at the specified index within the ItemCollection.

public DependencyObject ContainerFromIndex(Int32 index)public DependencyObject ContainerFromIndex(Int32 index)Public Function ContainerFromIndex(index As Int32) As DependencyObject
Parameters
index
System.Int32 System.Int32 System.Int32

The index of the item to retrieve.

Returns

The container for the item at the specified index within the item collection, if the item has a container; otherwise, null.

Attributes

ContainerFromItem(Object) ContainerFromItem(Object) ContainerFromItem(Object)

Note

ContainerFromItem may be altered or unavailable for releases after Windows 8.1. Instead, use ItemsControl.ContainerFromItem.

Returns the container corresponding to the specified item.

public DependencyObject ContainerFromItem(Object item)public DependencyObject ContainerFromItem(Object item)Public Function ContainerFromItem(item As Object) As DependencyObject
Parameters
item
System.Object System.Object System.Object

The item to retrieve the container for.

Returns

A container that corresponds to the specified item, if the item has a container and exists in the collection; otherwise, null.

Attributes

GenerateNext(Boolean) GenerateNext(Boolean) GenerateNext(Boolean)

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

public DependencyObject GenerateNext(Boolean isNewlyRealized)public DependencyObject GenerateNext(Boolean isNewlyRealized)Public Function GenerateNext(isNewlyRealized As Boolean) As DependencyObject
Parameters
isNewlyRealized
System.Boolean System.Boolean System.Boolean

true if the returned DependencyObject is newly generated (realized); otherwise, false.

Returns

A DependencyObject that is the container element that is used to display the next item.

Attributes

GeneratorPositionFromIndex(Int32) GeneratorPositionFromIndex(Int32) GeneratorPositionFromIndex(Int32)

Gets the generated position of the item at the specified index.

public GeneratorPosition GeneratorPositionFromIndex(Int32 itemIndex)public GeneratorPosition GeneratorPositionFromIndex(Int32 itemIndex)Public Function GeneratorPositionFromIndex(itemIndex As Int32) As GeneratorPosition
Parameters
itemIndex
System.Int32 System.Int32 System.Int32

The index of the item to retrieve the position of.

Returns

The position of the item as generated by the ItemContainerGenerator.

Attributes

GetItemContainerGeneratorForPanel(Panel) GetItemContainerGeneratorForPanel(Panel) GetItemContainerGeneratorForPanel(Panel)

Returns the ItemContainerGenerator that is appropriate for use by the specified panel.

public ItemContainerGenerator GetItemContainerGeneratorForPanel(Panel panel)public ItemContainerGenerator GetItemContainerGeneratorForPanel(Panel panel)Public Function GetItemContainerGeneratorForPanel(panel As Panel) As ItemContainerGenerator
Parameters
panel
Panel Panel Panel

The panel for which to return an appropriate ItemContainerGenerator.

Returns
Attributes

IndexFromContainer(DependencyObject) IndexFromContainer(DependencyObject) IndexFromContainer(DependencyObject)

Note

IndexFromContainer may be altered or unavailable for releases after Windows 8.1. Instead, use ItemsControl.IndexFromContainer.

Returns the index to the item that has the specified, generated container.

public int IndexFromContainer(DependencyObject container)public int IndexFromContainer(DependencyObject container)Public Function IndexFromContainer(container As DependencyObject) As int
Parameters
container
DependencyObject DependencyObject DependencyObject

The generated container to retrieve the item index for.

Returns
int int int

The index to the item that corresponds to the specified generated container.

Attributes

IndexFromGeneratorPosition(GeneratorPosition) IndexFromGeneratorPosition(GeneratorPosition) IndexFromGeneratorPosition(GeneratorPosition)

Returns the index that maps to the specified GeneratorPosition.

public int IndexFromGeneratorPosition(GeneratorPosition position)public int IndexFromGeneratorPosition(GeneratorPosition position)Public Function IndexFromGeneratorPosition(position As GeneratorPosition) As int
Parameters
Returns
int int int

The index that maps to the specified GeneratorPosition.

Attributes

ItemFromContainer(DependencyObject) ItemFromContainer(DependencyObject) ItemFromContainer(DependencyObject)

Note

ItemFromContainer may be altered or unavailable for releases after Windows 8.1. Instead, use ItemsControl.ItemFromContainer.

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

public PlatForm::Object ItemFromContainer(DependencyObject container)public object ItemFromContainer(DependencyObject container)Public Function ItemFromContainer(container As DependencyObject) As object
Parameters
container
DependencyObject DependencyObject DependencyObject

The DependencyObject that corresponds to the item to be returned.

Returns
object object object

The contained item, or the container if it does not contain an item.

Attributes

PrepareItemContainer(DependencyObject) PrepareItemContainer(DependencyObject) PrepareItemContainer(DependencyObject)

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

public void PrepareItemContainer(DependencyObject container)public void PrepareItemContainer(DependencyObject container)Public Function PrepareItemContainer(container As DependencyObject) As void
Parameters
container
DependencyObject DependencyObject DependencyObject

The container to prepare. Typically, container is the result of the previous call to GenerateNext.

Attributes

Recycle(GeneratorPosition, Int32) Recycle(GeneratorPosition, Int32) Recycle(GeneratorPosition, Int32)

Disassociates item containers from their data items and saves the containers so they can be reused later for other data items.

public void Recycle(GeneratorPosition position, Int32 count)public void Recycle(GeneratorPosition position, Int32 count)Public Function Recycle(position As GeneratorPosition, count As Int32) As void
Parameters
position
GeneratorPosition GeneratorPosition GeneratorPosition

The zero-based index of the first element to reuse. position must refer to a previously generated (realized) item.

count
System.Int32 System.Int32 System.Int32

The number of elements to reuse, starting at position.

Attributes

Remove(GeneratorPosition, Int32) Remove(GeneratorPosition, Int32) Remove(GeneratorPosition, Int32)

Removes one or more generated (realized) items.

public void Remove(GeneratorPosition position, Int32 count)public void Remove(GeneratorPosition position, Int32 count)Public Function Remove(position As GeneratorPosition, count As Int32) As void
Parameters
position
GeneratorPosition GeneratorPosition GeneratorPosition

The index of the element to remove. position must refer to a previously generated (realized) item, which means its offset must be zero.

count
System.Int32 System.Int32 System.Int32

The number of elements to remove, starting at position.

Attributes

RemoveAll() RemoveAll() RemoveAll()

Removes all generated (realized) items.

public void RemoveAll()public void RemoveAll()Public Function RemoveAll() As void
Attributes

StartAt(GeneratorPosition, GeneratorDirection, Boolean) StartAt(GeneratorPosition, GeneratorDirection, Boolean) StartAt(GeneratorPosition, GeneratorDirection, Boolean)

Prepares the generator to generate items, starting at the specified GeneratorPosition and moving in the specified GeneratorDirection. This method also controls whether or not to start at a generated (realized) item.

public void StartAt(GeneratorPosition position, GeneratorDirection direction, Boolean allowStartAtRealizedItem)public void StartAt(GeneratorPosition position, GeneratorDirection direction, Boolean allowStartAtRealizedItem)Public Function StartAt(position As GeneratorPosition, direction As GeneratorDirection, allowStartAtRealizedItem As Boolean) As void
Parameters
position
GeneratorPosition GeneratorPosition GeneratorPosition

A GeneratorPosition that specifies the position of the item to start generating items at.

direction
GeneratorDirection GeneratorDirection GeneratorDirection

Specifies the position of the item to start generating items at.

allowStartAtRealizedItem
System.Boolean System.Boolean System.Boolean

Specifies whether to start at a generated (realized) item.

Attributes

Stop() Stop() Stop()

Disposes the ItemContainerGenerator.

public void Stop()public void Stop()Public Function Stop() As void
Attributes

Events

ItemsChanged ItemsChanged ItemsChanged

Occurs when the contents of the items collection changes.

public event ItemsChangedEventHandler ItemsChangedpublic event ItemsChangedEventHandler ItemsChangedPublic Event ItemsChanged
Attributes