title: Xamarin.Forms loading large dataset with Android
body: <p>I've been working on a Xamarin Forms project and I'm having trouble loading data into the Android application.  It loads fine for iOS and UWP, but on Android it takes forever.  This is happening on two different screens but I'm assuming the problem is the same.  I'm sure there are better ways to load the data than what I am using.</p>
  
  <p>This is the first screen I'm having trouble with on Android (screenshot from UWP):
  <a href="https://i.stack.imgur.com/fZHcv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fZHcv.png" alt="Merchandise Listing"></a></p>
  
  <p>It loads 15 products in each category into a horizontal scroller.  The "See All" link loads all of the products in that category into a vertical scrolling grid.  That's the second screen I'm having trouble with.</p>
  
  <p>The code to load this view is:</p>
  
  <pre><code>     var scroller = new TLScrollView
       {
            Orientation = ScrollOrientation.Horizontal,
            ItemTemplate = new DataTemplate(() =&gt; ViewFactory.Merchandise.Invoke()),
            HeightRequest = 320,
            Padding = new Thickness(0, 0, 0, 10)
       };
  
       scroller.SetBinding(TLScrollView.ItemsSourceProperty, nameof(items));
       scroller.ItemsSource = items.OrderByDescending(d =&gt; d.Cost).Take(15);
  </code></pre>
  
  <p>The ViewFactory code is:</p>
  
  <pre><code>public static Func&lt;View&gt; Merchandise { get; } = () =&gt;
  {
      var mainGrid = new Grid() { WidthRequest = 250, Margin = 5 };
  
      mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
      mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(25, GridUnitType.Absolute) });
      mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(25, GridUnitType.Absolute) });
      mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(25, GridUnitType.Absolute) });
      mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(35, GridUnitType.Absolute) });
  
      var nameLabel = new Label() { Text = "Casket Name", LineBreakMode = LineBreakMode.TailTruncation, HorizontalTextAlignment = TextAlignment.Center };
      var materialLabel = new Label() { Text = "MaterialName", HorizontalTextAlignment = TextAlignment.Center };
      var costLabel = new Label() { Text = "Cost", HorizontalTextAlignment = TextAlignment.Center };
  
      nameLabel.SetBinding(Label.TextProperty, "ItemName");
      materialLabel.SetBinding(Label.TextProperty, "Material");
      costLabel.SetBinding(Label.TextProperty, "CostFormatted");
  
      GlobalModel globalModel = App.Current.MainPage.BindingContext as GlobalModel;
  
      var catalogImage = new CachedImage
      {
          HorizontalOptions = LayoutOptions.FillAndExpand,
          VerticalOptions = LayoutOptions.FillAndExpand,
          Aspect = Aspect.AspectFit,
          LoadingPlaceholder = "MAFSLoader.gif",
          CacheDuration = TimeSpan.FromDays(10),
          RetryCount = 1,
          RetryDelay = 100
      };
  
      catalogImage.BindingContextChanged += (s, o) =&gt; {
          catalogImage.Source = null;
          var item = catalogImage.BindingContext as CatalogItem;
  
          if (item == null) return;
  
          catalogImage.Source = item.SmallURL;
      };
  
      var buttonStyle = (Style)Application.Current.Resources["ButtonStyle"];
      var addToCartButton = new Button { Text = "Add to Cart", BackgroundColor = Color.FromHex("#486E8E"), WidthRequest = 250, Style = buttonStyle };
      addToCartButton.SetBinding(Button.CommandParameterProperty, "ItemID");
  
      var imgTapGesture = new TapGestureRecognizer()
      {
          Command = new Command(() =&gt;
          {
              if (addToCartButton.CommandParameter == null)
              {
                  addToCartButton.SetBinding(Button.CommandParameterProperty, "ItemId");
              }
  
              var dictionary = new Dictionary&lt;string, string&gt;();
              dictionary.Add(globalModel.CurrentFuneralHomeKey, addToCartButton.CommandParameter.ToString());
              globalModel.ProductDetail.Execute(dictionary);
          })
      };
      catalogImage.GestureRecognizers.Add(imgTapGesture);
  
      addToCartButton.Clicked += new EventHandler(async delegate (Object o, EventArgs a)
      {
          var button = ((Button)o);
  
          globalModel.AddToCart.Execute(button.BindingContext);
  
          if (button.BindingContext.GetType() == typeof(Data.Corner))
          {
              await App.Current.MainPage.DisplayAlert("Shopping Cart", "You've added " + (button.BindingContext as Data.Corner).ItemName + " to your cart.", null, "OK");
          }
      });
  
      mainGrid.Children.Add(catalogImage, 0, 0);
      mainGrid.Children.Add(nameLabel, 0, 1);
      mainGrid.Children.Add(materialLabel, 0, 2);
      mainGrid.Children.Add(costLabel, 0, 3);
      mainGrid.Children.Add(addToCartButton, 0, 4);
  
  
      return mainGrid;
  };
  </code></pre>
  
  <p>If anyone could point me in the right direction I'd be very grateful!</p>