@ -403,7 +403,7 @@ namespace Avalonia.Controls
if ( firstIndex = = - 1 )
if ( firstIndex = = - 1 )
{
{
estimatedElementSize = EstimateElementSizeU ( ) ;
estimatedElementSize = EstimateElementSizeU ( ) ;
firstIndex = ( int ) ( viewportStart / estimatedElementSize ) ;
firstIndex = Math . Min ( ( int ) ( viewportStart / estimatedElementSize ) , maxIndex ) ;
firstIndexU = firstIndex * estimatedElementSize ;
firstIndexU = firstIndex * estimatedElementSize ;
}
}
@ -411,13 +411,13 @@ namespace Avalonia.Controls
{
{
if ( estimatedElementSize = = - 1 )
if ( estimatedElementSize = = - 1 )
estimatedElementSize = EstimateElementSizeU ( ) ;
estimatedElementSize = EstimateElementSizeU ( ) ;
lastIndex = ( int ) ( viewportEnd / estimatedElementSize ) ;
lastIndex = Math . Min ( ( int ) ( viewportEnd / estimatedElementSize ) , maxIndex ) ;
}
}
return new MeasureViewport
return new MeasureViewport
{
{
firstIndex = MathUtilities . Clamp ( firstIndex , 0 , maxIndex ) ,
firstIndex = firstIndex ,
lastIndex = MathUtilities . Clamp ( lastIndex , 0 , maxIndex ) ,
lastIndex = lastIndex ,
viewportUStart = viewportStart ,
viewportUStart = viewportStart ,
viewportUEnd = viewportEnd ,
viewportUEnd = viewportEnd ,
startU = firstIndexU ,
startU = firstIndexU ,
@ -1131,6 +1131,7 @@ namespace Avalonia.Controls
// The removed range was before the realized elements. Update the first index and
// The removed range was before the realized elements. Update the first index and
// the indexes of the realized elements.
// the indexes of the realized elements.
_f irstIndex - = count ;
_f irstIndex - = count ;
_ startUUnstable = true ;
var newIndex = _f irstIndex ;
var newIndex = _f irstIndex ;
for ( var i = 0 ; i < _ elements . Count ; + + i )
for ( var i = 0 ; i < _ elements . Count ; + + i )