Class StackView
A StackView is a container that can contain multiple items. It is similar to a stack of cards. The items are added to the stack using the Push method. The top item is the current item. The current item can be removed using the Pop method. The item below the current item becomes the new current item. The current item can be replaced using the Replace method. The item below the current item is removed and the new item is added.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class StackView : BaseVisualElement, IEventHandler, IVisualElementScheduler, IExperimentalFeatures, ITransitionAnimations, ITransform, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder
Constructors
StackView()
The constructor of the StackView.
Declaration
public StackView()
Fields
ussClassName
The main styling class of the StackView. This is the class that is used in the USS file.
Declaration
public const string ussClassName = "appui-stackview"
Field Value
Type | Description |
---|---|
string |
Properties
currentItem
The current item in the stack.
Declaration
public StackViewItem currentItem { get; }
Property Value
Type | Description |
---|---|
StackViewItem |
depth
The depth of the stack.
Declaration
public int depth { get; }
Property Value
Type | Description |
---|---|
int |
initialItem
The initial item to add to the stack.
Declaration
public VisualElement initialItem { get; set; }
Property Value
Type | Description |
---|---|
VisualElement |
isBusy
Check if the StackView has any active animation.
Declaration
public bool isBusy { get; }
Property Value
Type | Description |
---|---|
bool |
isEmpty
Check if the stack is empty.
Declaration
public bool isEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
popEnterAnimation
The animation to use on the newly active item when an item is popped from the stack.
Declaration
public AnimationDescription popEnterAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
popExitAnimation
The animation to use on the current item when it is popped from the stack.
Declaration
public AnimationDescription popExitAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
pushEnterAnimation
The animation to use on the newly active item when it is pushed to the stack.
Declaration
public AnimationDescription pushEnterAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
pushExitAnimation
The animation to use on the current item when a new item is pushed to the stack.
Declaration
public AnimationDescription pushExitAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
replaceEnterAnimation
The animation to use on the newly active item when it is replaced in the stack.
Declaration
public AnimationDescription replaceEnterAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
replaceExitAnimation
The animation to use on the current item when it is replaced in the stack.
Declaration
public AnimationDescription replaceExitAnimation { get; set; }
Property Value
Type | Description |
---|---|
AnimationDescription |
Methods
ClearStack()
Removes all items from the stack.
Declaration
public void ClearStack()
Pop(StackViewItem, StackViewOperation)
Pops one or more items off the stack.
Declaration
public StackViewItem Pop(StackViewItem item, StackViewOperation operation = StackViewOperation.PopTransition)
Parameters
Type | Name | Description |
---|---|---|
StackViewItem | item | If the item argument is specified, all items down to (but not including) item will be popped. If item is null, all items down to (but not including) the first item is popped. |
StackViewOperation | operation | The type of transition to use during the process. |
Returns
Type | Description |
---|---|
StackViewItem | Returns the last item removed from the stack. |
Pop(StackViewOperation)
Pops one or more items off the stack. Only the current item is popped.
Declaration
public StackViewItem Pop(StackViewOperation operation = StackViewOperation.PopTransition)
Parameters
Type | Name | Description |
---|---|---|
StackViewOperation | operation | The type of transition to use during the process. |
Returns
Type | Description |
---|---|
StackViewItem | Returns the last item removed from the stack. |
Push(VisualElement, Action, StackViewOperation)
Pushes an item onto the stack using an optional operation.
Declaration
public StackViewItem Push(VisualElement item, Action callback = null, StackViewOperation operation = StackViewOperation.PushTransition)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | item | The item to push onto the stack. |
Action | callback | The callback to call when the operation is completed. |
StackViewOperation | operation | The type of transition to use during the process. |
Returns
Type | Description |
---|---|
StackViewItem | Returns the item that became current. |
Replace(StackViewItem, VisualElement, Action, StackViewOperation)
Replaces one or more items on the stack with the specified item and optional operation.
Declaration
public StackViewItem Replace(StackViewItem target, VisualElement item, Action callback = null, StackViewOperation operation = StackViewOperation.ReplaceTransition)
Parameters
Type | Name | Description |
---|---|---|
StackViewItem | target | If the target argument is specified, all items down to the target item will be replaced. If target is null, all items in the stack will be replaced. |
VisualElement | item | The item that will be used as replacement. |
Action | callback | The callback to call when the operation is completed. |
StackViewOperation | operation | The type of transition to use during the process. |
Returns
Type | Description |
---|---|
StackViewItem | Returns the item that became current. |
Events
currentItemChanged
Event emitted when the current item in the stack changes.
Declaration
public event Action currentItemChanged
Event Type
Type | Description |
---|---|
Action |
Remarks
The event is emitted at the end of the animation (if any).
The event is emitted after the currentItemChanging event.
currentItemChanging
Event emitted when the current item in the stack is about to change.
Declaration
public event Action currentItemChanging
Event Type
Type | Description |
---|---|
Action |
Remarks
The event is emitted at the beginning of the animation (if any). Afterwards, currentItemChanged is emitted.