FREE TRIAL

|

☀
☾

ListView.TryDetach

TryDetach(int, out ItemView, Transform)

Transfers ownership of the ItemView representing the object at data source index sourceIndex from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.

Remarks

If the detach succeeds, the listItem's parent will be set to newParent.

Because the now detached item is no longer a child of the ListView, the gesture handlers registered on the ListView will not fire for the detached item anymore. To continue receiving the same events while the item is detached, subscribe to them on the detached UIBlock directly (or its new parent) via AddGestureHandler<TGesture>(UIEventHandler<TGesture>, Boolean) and then use RemoveGestureHandler<TGesture>(UIEventHandler<TGesture>) before TryReattach(ItemView) to avoid having multiple gesture handlers simultaneously.

Declaration
public bool TryDetach(int sourceIndex, out ItemView listItem, Transform newParent = null)
Parameters
Type Name Description
int sourceIndex

The index of the object in the data source

ItemView listItem

The list item visual reprensenting the object at index sourceIndex

Transform newParent

The transform to set as the new parent of listItem

Returns
Type Description
bool

true if listItem is loaded into view and gets detached succesfully. Otherwise returns false.

TryDetach(ItemView, Transform)

Transfers ownership of the detached listItem from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.

Remarks

If the detach succeeds, the listItem's parent will be set to newParent.

Because the now detached item is no longer a child of the ListView, the gesture handlers registered on the ListView will not fire for the detached item anymore. To continue receiving the same events while the item is detached, subscribe to them on the detached UIBlock directly (or its new parent) via AddGestureHandler<TGesture>(UIEventHandler<TGesture>, Boolean) and then use RemoveGestureHandler<TGesture>(UIEventHandler<TGesture>) before TryReattach(ItemView) to avoid having multiple gesture handlers simultaneously.

Declaration
public bool TryDetach(ItemView listItem, Transform newParent = null)
Parameters
Type Name Description
ItemView listItem

The list item visual reprensenting the item

Transform newParent

The transform to set as the new parent of listItem

Returns
Type Description
bool

true if listItem is loaded into view and gets detached succesfully. Otherwise returns false.

See Also
TryDetach(ItemView, Transform)
TryReattach(ItemView)
☀
☾
In This Article
Legal EmailContact Github
Copyright © 2022 Supernova Technologies, LLC