When scrolling, you get the unbind and bind events and components are reused. But on ListView.Refresh()
all components are trashed and new ones are made. Is there a way to get the current components being used on the ListView
so I can manually reuse them?
I figured right after making the thread.
RegisterCallbacksOnTarget
protected override void RegisterCallbacksOnTarget() {
base.RegisterCallbacksOnTarget();
unity_content_container = target.Q("unity-content-container");
}
Before ListView.Refresh();
if (unity_content_container != null) {
VisualElement[] children = unity_content_container.Children().ToArray();
foreach (var e in children) {
ContainerCache.Enqueue(e);
}
}
Make Item
MakeItem = () => {
if (ContainerCache.Count > 0) {
return ContainerCache.Dequeue();
}
VisualElement VisualElement = new VisualElement();
VisualElement.style.flexDirection = FlexDirection.Row;
VisualElement.usageHints = UsageHints.GroupTransform;
return VisualElement;
};