@@ -194,10 +194,13 @@ private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventAr
194
194
var item = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . SkipWhile ( x => x . Value . Y <= verticalOffset + uiElement . ActualHeight ) . Select ( x => x . Key ) . FirstOrDefault ( ) ;
195
195
if ( item == null )
196
196
{
197
- // Last loaded item is fully visible, ge thet next one from bound item source
198
- var index = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . Last ( ) . Key . GetIndex ( ) ;
199
- var source = ( System . Collections . IList ) uiElement . ItemsSource ;
200
- uiElement . ScrollIntoView ( source [ Math . Min ( Math . Max ( index + 1 , 0 ) , source . Count - 1 ) ] , null ) ;
197
+ if ( dataGridRowsPosition . Any ( ) )
198
+ {
199
+ // Last loaded item is fully visible, ge thet next one from bound item source
200
+ var index = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . Last ( ) . Key . GetIndex ( ) ;
201
+ var source = ( System . Collections . IList ) uiElement . ItemsSource ;
202
+ uiElement . ScrollIntoView ( source [ Math . Min ( Math . Max ( index + 1 , 0 ) , source . Count - 1 ) ] , null ) ;
203
+ }
201
204
}
202
205
else
203
206
{
@@ -211,10 +214,13 @@ private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventAr
211
214
var item = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . TakeWhile ( x => x . Value . Y + x . Value . Height <= scrollBar . Value ) . Select ( x => x . Key ) . LastOrDefault ( ) ;
212
215
if ( item == null )
213
216
{
214
- // First loaded item is fully visible, ge thet previous one from bound item source
215
- var index = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . First ( ) . Key . GetIndex ( ) ;
216
- var source = ( System . Collections . IList ) uiElement . ItemsSource ;
217
- uiElement . ScrollIntoView ( source [ Math . Min ( Math . Max ( index - 1 , 0 ) , source . Count - 1 ) ] , null ) ;
217
+ if ( dataGridRowsPosition . Any ( ) )
218
+ {
219
+ // First loaded item is fully visible, ge thet previous one from bound item source
220
+ var index = dataGridRowsPosition . OrderBy ( x => x . Value . Y ) . First ( ) . Key . GetIndex ( ) ;
221
+ var source = ( System . Collections . IList ) uiElement . ItemsSource ;
222
+ uiElement . ScrollIntoView ( source [ Math . Min ( Math . Max ( index - 1 , 0 ) , source . Count - 1 ) ] , null ) ;
223
+ }
218
224
}
219
225
else
220
226
{
0 commit comments