Instantiating items in scrollview? #19907
Replies: 4 comments 2 replies
-
I'm not entirely sure what actually you are trying to do but, there are two kinds of virtualizations as far as I know. One is UI virtualization and the other is data virtualization (or sometimes called Lazy Loading). Avalonia's ItemsControl (or ListBox) already implements UI virtualization but... only for VirtualizingStackPanel (for now?). In your example, you are using UniformGrid, so UI virtualization won't be enabled as far as I know (somebody correct me if I'm wrong). Next, Data virtualization (or Lazy Loading) is a technique that only loads/renders items when actually needed (e.g. when they became visible in the viewport of scrollviewer). Here are the code snippet how to get visible items in the scrollviewer. Once you get the items, you can instantiate objects, load images etc. |
Beta Was this translation helpful? Give feedback.
-
|
Take a look at #13605 |
Beta Was this translation helpful? Give feedback.
-
|
A tile engine is not a good use case for ScrollViewer + ItemsControl + individual Image elements. Just custom draw it and you'll be much faster, especially with 8x8. Not everything needs to be done with basic controls, especially "centerpiece" controls. You still get to move fast with basic controls in other UI areas while being very efficient in your most demanding control(s). |
Beta Was this translation helpful? Give feedback.
-
|
I created a UniformGrid that supports virtualization and waterfall pagination (it triggers the loading of more data when the page is almost at the bottom), and I think it might solve your problem: https://github.com/kyuranger/Avalonia.SVirtualizingWrapPanel |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was looking up how to do this and google suggested virtualization so I am not drawing the entire list of items at once.
However how do I actually load these items?
The creating and loading needs to be virtualized also because doing so for billions of images at once is not good.
Beta Was this translation helpful? Give feedback.
All reactions