You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a problem with bring in to view calls for repeater items. This issue is related to repeater virtualization where item needs to be created and scrollbar position needs to be calculated before item can be brought in to view.
For this to work GetOrCreateElement was made public but usage of it is not relay user friendly and can cause some issues.
After call to GetOrCreateElement is made user will get new item but calling BringInToView will result in empty repeater viewport if user does not wait for layout pass to be finished.
This not only mean user is not quite sure when can BringInToView be called but also additional items can be added to repeaters source collection before layout pass is over and this can also lead to empty viewport.
So only option user has is to force layout update after GetOrCreateElement to make sure all is ready for BringInToView call.
I wonder if we can make BringInToView safer feature to use as I imagine bringing things in to view in the repeater is one of things users will need.
Layout updates can be forced by app code rather than relying on the built-in layout system behavior by using the UpdateLayout method. However, that is not generally recommended. It is usually unnecessary and can cause poor performance if overused.
Which is also true for Avalonia, so we make it a bit more difficult by having to get the layout manager etc. but given that doing a manual layout is necessary for ItemsRepeater we could expose UpdateLayout on ItemsRepeater.
There seems to be a problem with bring in to view calls for repeater items. This issue is related to repeater virtualization where item needs to be created and scrollbar position needs to be calculated before item can be brought in to view.
For this to work GetOrCreateElement was made public but usage of it is not relay user friendly and can cause some issues.
After call to GetOrCreateElement is made user will get new item but calling BringInToView will result in empty repeater viewport if user does not wait for layout pass to be finished.
This not only mean user is not quite sure when can BringInToView be called but also additional items can be added to repeaters source collection before layout pass is over and this can also lead to empty viewport.
So only option user has is to force layout update after GetOrCreateElement to make sure all is ready for BringInToView call.
I wonder if we can make BringInToView safer feature to use as I imagine bringing things in to view in the repeater is one of things users will need.
To demonstrate this I created small repository: https://github.com/igorstefus/AvaloniaRepeaterProblem/tree/master/RepeaterProblem
The text was updated successfully, but these errors were encountered: