-
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 14 replies
-
You should chunk more than 1 item per delay. I suspect 10-100 is fine with how simple your UI elements are. This will speed things up a lot and may be "good enough". Besides that, you can do much better if you can either: 1. create a design with fixed item width. 2. separate or count results by number of glyphs. The last line with single glyph should break to the next line if there's extra space. The first two glyph entry will always start on a new line and leftmost. This makes the calculation much easier as you can use fixed width sizing (even if it's per-group: 1, 2, 3 characters, etc). Fixed sizing means you can use multiplication to determine height and not measure every element. This is effectively instantaneous at the cost of some flexibility. If you can do that, then you throw your virtualization away. Create Avalonia/samples/RenderDemo/Pages/GlyphRunPage.xaml.cs Lines 56 to 80 in b92bb93 |
Beta Was this translation helpful? Give feedback.
-
IF _ViewModel.CandidatesOC is an ObservableCollection, this is somewhat "normal". The collection will fire events for each Add(). |
Beta Was this translation helpful? Give feedback.
-
AddRange will loop on the basic Add and will raise three events for each item added. Therefore for each add, there will be a measure, arrange, and virtualization pass. Same problem. |
Beta Was this translation helpful? Give feedback.
-
Use ObservableCollectionExtended and SuspendNotifications when for add item,and then Dispose |
Beta Was this translation helpful? Give feedback.
-
Following @LaurentInSeattle 's answer, I suddenly remembered that I'd been using ObservableCollection in ItemSource bindings, without considering other data formats. Then, on a whim, I asked Grok (an AI model) if it had any suggestions for better data formats. Grok suggested using AvaloniaList, a data format developed by Avalonia that offers better performance than ObservableCollection and natively supports methods like AddRange. I tested it, and with AvaloniaList, adding 50 items in a batch didn't cause any noticeable lag (though there was still a lag of around 100ms), which I find acceptable. |
Beta Was this translation helpful? Give feedback.
Following @LaurentInSeattle 's answer, I suddenly remembered that I'd been using ObservableCollection in ItemSource bindings, without considering other data formats. Then, on a whim, I asked Grok (an AI model) if it had any suggestions for better data formats. Grok suggested using AvaloniaList, a data format developed by Avalonia that offers better performance than ObservableCollection and natively supports methods like AddRange. I tested it, and with AvaloniaList, adding 50 items in a batch didn't cause any noticeable lag (though there was still a lag of around 100ms), which I find acceptable.