title: How to make CollectionView's item loop when scrolling in Xamarin
body: <p>I am using CollectionView to display data by scroll. However, there is a problem that after the data, it scrolls iteratively? <strong>Means after I reach the last element, it will show me the first element again.</strong> I know CarouselView has a property called loop for that. However, for some reason, I don't use CarouselView. This is the code I used:</p>
  <p><strong>PageOne.xaml</strong></p>
  <pre><code>&lt;CollectionView x:Name=&quot;_data&quot; HeightRequest=&quot;115&quot; ItemsUpdatingScrollMode=&quot;KeepItemsInView&quot; HorizontalScrollBarVisibility=&quot;Never&quot; VerticalScrollBarVisibility=&quot;Never&quot; Scrolled=&quot;_data_Scrolled&quot;&gt;
      &lt;CollectionView.ItemsLayout&gt;
          &lt;LinearItemsLayout Orientation=&quot;Horizontal&quot; SnapPointsType=&quot;MandatorySingle&quot; SnapPointsAlignment=&quot;Start&quot; /&gt;
      &lt;/CollectionView.ItemsLayout&gt;
      &lt;CollectionView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackLayout Orientation=&quot;Horizontal&quot; HorizontalOptions=&quot;FillAndExpand&quot;&gt;
                  ...
              &lt;/StackLayout&gt;                                                                    
          &lt;/DataTemplate&gt;
      &lt;/CollectionView.ItemTemplate&gt;
  &lt;/CollectionView&gt;
  </code></pre>
  <p><strong>PageOne.xaml.cs</strong></p>
  <p>Do I autorun items in CollectionView</p>
  <pre><code>....
  Device.StartTimer(TimeSpan.FromSeconds(4), (Func&lt;bool&gt;)(() =&gt;
  {
      _data.ScrollTo(listData.Count + 2, -1, ScrollToPosition.Start, true);
      //return true;
  }));
  </code></pre>
  <p><strong>In my code, check the _data_Scrolled event when the last element is reached</strong></p>
  <pre><code>private void _data_Scrolled(object sender, ItemsViewScrolledEventArgs e)
  {
      if(e.LastVisibleItemIndex + 1 == countHotSeling)
      {
          Device.StartTimer(TimeSpan.FromSeconds(4), (Func&lt;bool&gt;)(() =&gt;
          {
              _data.ScrollTo(listData.Count - 2, +1, ScrollToPosition.Start, true);
              return true;
          }));
      }    
  }
  </code></pre>
  <p>When t debug, it actually jumps to the event when the last element is reached. However, it does not loop?</p>
  <p>Looking forward to everyone's help. Thank you!</p>