ItemContainerGenerator Class
Namespace: Avalonia.Controls.GeneratorsAssembly: Avalonia.Controls (in Avalonia.Controls.dll) Version: 11.3.999
public class ItemContainerGenerator
Public Class ItemContainerGenerator
type ItemContainerGenerator = class end
- Inheritance
- Object ItemContainerGenerator
- Derived
When creating a container for an item from a
VirtualizingPanel, the following
process should be followed:
-
NeedsContainer(Object, Int32, Object) should first be called to
determine whether the item needs a container. This method will return true if the item
should be wrapped in a container control, or false if the item itself can be used as a
container.
- If
NeedsContainer(Object, Int32, Object) returns true then the
CreateContainer(Object, Int32, Object) method should be called to create a new container, passing
the recycle key returned from
NeedsContainer(Object, Int32, Object).
- If the panel supports recycling and the recycle key is non-null then the recycle key
should be recorded for the container (e.g. in an attached property or the realized
container list).
-
PrepareItemContainer(Control, Object, Int32) method should be called for the
container.
- The container should then be added to the panel using
AddInternalChild(Control)
- Finally,
ItemContainerPrepared(Control, Object, Int32) should be called.
NOTE: If
NeedsContainer(Object, Int32, Object) in the first step above
returns false then the above steps should be carried out a single time: the first time the
item is displayed. Otherwise the steps should be carried out each time a new container is
realized for an item.
When unrealizing a container, the following process should be followed:
- If
NeedsContainer(Object, Int32, Object) for the item returned false
then the item cannot be unrealized or recycled.
- Otherwise,
ClearItemContainer(Control) should be called for the container
- If recycling is supported by the panel and the container then the container should be
added to a recycle pool keyed on the recycle key returned from
NeedsContainer(Object, Int32, Object). It is assumed that recycled
containers will not be removed from the panel but instead hidden from view using
e.g. `container.IsVisible = false`.
- If recycling is not supported then the container should be removed from the panel.
When recycling an unrealized container, the following process should be followed:
-
NeedsContainer(Object, Int32, Object) should be called to determine
whether the item needs a container, and if so, the recycle key.
- A container should be taken from the recycle pool keyed on the returned recycle key.
- The container should be made visible.
-
PrepareItemContainer(Control, Object, Int32) method should be called for the
container.
-
ItemContainerPrepared(Control, Object, Int32) should be called.
NOTE: Although this class is similar to that found in WPF/UWP, in Avalonia this class only
concerns itself with generating and clearing item containers; it does not maintain a
record of the currently realized containers, that responsibility is delegated to the
items panel.
| ClearItemContainer(Control) |
Undoes the effects of the PrepareItemContainer(Control, Object, Int32) method.
|
| CreateContainer(Object, Int32, Object) |
Creates a new container control.
|
| Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
| GetHashCode | Serves as the default hash function. (Inherited from Object) |
| GetType | Gets the Type of the current instance. (Inherited from Object) |
| ItemContainerIndexChanged(Control, Int32, Int32) |
Called when the index for a container changes due to an insertion or removal in the
items collection.
|
| ItemContainerPrepared(Control, Object, Int32) |
Notifies the ItemsControl that a container has been fully prepared to
display an item.
|
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
| NeedsContainer(Object, Int32, Object) |
Determines whether the specified item needs to be wrapped in a container control.
|
| PrepareItemContainer(Control, Object, Int32) |
Prepares the specified element as the container for the corresponding item.
|
| ToString | Returns a string that represents the current object. (Inherited from Object) |