Show / Hide Table of Contents

Class ItemContainerGenerator

An ItemContainerGenerator is responsible for generating the UI on behalf of its host (e.g. ItemsControl). It maintains the association between the items in the control's data view and the corresponding UIElements. The control's item-host can ask the ItemContainerGenerator for a Generator, which does the actual generation of UI.

Inheritance
System.Object
ItemContainerGenerator
Implements
IRecyclingItemContainerGenerator
IItemContainerGenerator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public sealed class ItemContainerGenerator : IRecyclingItemContainerGenerator, IItemContainerGenerator

Methods

| Improve this Doc View Source

ContainerFromIndex(Int32)

Return the UI element corresponding to the item at the given index within the ItemCollection.

Declaration
public DependencyObject ContainerFromIndex(int index)
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
DependencyObject
| Improve this Doc View Source

ContainerFromItem(Object)

Return the UI element corresponding to the given item. Returns null if the item does not belong to the item collection, or if no UI has been generated for it.

Declaration
public DependencyObject ContainerFromItem(object item)
Parameters
Type Name Description
System.Object item
Returns
Type Description
DependencyObject
| Improve this Doc View Source

GeneratorPositionFromIndex(Int32)

Map an index into the items collection to a GeneratorPosition.

Declaration
public GeneratorPosition GeneratorPositionFromIndex(int itemIndex)
Parameters
Type Name Description
System.Int32 itemIndex
Returns
Type Description
GeneratorPosition
| Improve this Doc View Source

IndexFromContainer(DependencyObject)

Given a generated UI element, return the index of the corresponding item within the ItemCollection.

Declaration
public int IndexFromContainer(DependencyObject container)
Parameters
Type Name Description
DependencyObject container
Returns
Type Description
System.Int32
| Improve this Doc View Source

IndexFromGeneratorPosition(GeneratorPosition)

Map a GeneratorPosition to an index into the items collection.

Declaration
public int IndexFromGeneratorPosition(GeneratorPosition position)
Parameters
Type Name Description
GeneratorPosition position
Returns
Type Description
System.Int32
| Improve this Doc View Source

ItemFromContainer(DependencyObject)

Return the item corresponding to the given UI element. If the element was not generated as a container for this generator's host, the method returns DependencyProperty.UnsetValue.

Declaration
public object ItemFromContainer(DependencyObject container)
Parameters
Type Name Description
DependencyObject container
Returns
Type Description
System.Object

Events

| Improve this Doc View Source

ItemsChanged

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

Declaration
public event ItemsChangedEventHandler ItemsChanged
Event Type
Type Description
ItemsChangedEventHandler

Explicit Interface Implementations

| Improve this Doc View Source

IItemContainerGenerator.GenerateNext(out Boolean)

Declaration
DependencyObject IItemContainerGenerator.GenerateNext(out bool isNewlyRealized)
Parameters
Type Name Description
System.Boolean isNewlyRealized
Returns
Type Description
DependencyObject
| Improve this Doc View Source

IItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel)

Return the ItemContainerGenerator appropriate for use by the given panel

Declaration
ItemContainerGenerator IItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel panel)
Parameters
Type Name Description
Panel panel
Returns
Type Description
ItemContainerGenerator
| Improve this Doc View Source

IItemContainerGenerator.PrepareItemContainer(DependencyObject)

Prepare the given element to act as the container for the corresponding item. This includes applying the container style, forwarding information from the host control (ItemTemplate, etc.), and other small adjustments.

Declaration
void IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
Parameters
Type Name Description
DependencyObject container

The container to prepare. Normally this is the result of the previous call to GenerateNext.

Remarks

This method must be called after the element has been added to the visual tree, so that resource references and inherited properties work correctly.

| Improve this Doc View Source

IItemContainerGenerator.Remove(GeneratorPosition, Int32)

Remove generated elements.

Declaration
void IItemContainerGenerator.Remove(GeneratorPosition position, int count)
Parameters
Type Name Description
GeneratorPosition position
System.Int32 count
| Improve this Doc View Source

IItemContainerGenerator.RemoveAll()

Remove all generated elements.

Declaration
void IItemContainerGenerator.RemoveAll()
| Improve this Doc View Source

IItemContainerGenerator.StartAt(GeneratorPosition, GeneratorDirection, Boolean)

Begin generating at the given position and direction

Declaration
IDisposable IItemContainerGenerator.StartAt(GeneratorPosition position, GeneratorDirection direction, bool allowStartAtRealizedItem)
Parameters
Type Name Description
GeneratorPosition position
GeneratorDirection direction
System.Boolean allowStartAtRealizedItem
Returns
Type Description
System.IDisposable
Remarks

This method must be called before calling GenerateNext. It returns an IDisposable object that tracks the lifetime of the generation loop. This method sets the generator's status to GeneratingContent; when the IDisposable is disposed, the status changes to ContentReady or Error, as appropriate.

| Improve this Doc View Source

IRecyclingItemContainerGenerator.Recycle(GeneratorPosition, Int32)

Declaration
void IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, int count)
Parameters
Type Name Description
GeneratorPosition position
System.Int32 count

Implements

IRecyclingItemContainerGenerator
IItemContainerGenerator
  • Improve this Doc
  • View Source