title: Why is my listview showing the item source data type?
body: <p>I'm not looking for a solution here, for I believe there's nothing that you can guys can gather to what's causing this in my specific case. But I was wondering if anyone has any insight at all as to what may be making this happen. We have 8K+ users daily. This issue only seems to affect a small percentage of our users, and seems to happen on wifi only. But essentially, this is what they see: </p>
  
  <p><a href="https://i.stack.imgur.com/1peA4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1peA4.png" alt="enter image description here"></a></p>
  
  <p>So it's showing the path of the item source of the list view. Instead of the layout it's supposed to show. The layout is pretty complicated so I won't post it initially, but if anyone wants to see it then I'll surely post it here too. Just really looking for insights here. It seems to only happen when we're showing images, (we have an alternative listview for users that don't want to see images). </p>
  
  <p><strong>UPDATE (CustomGridCell)</strong></p>
  
  <p>Here's my layout:</p>
  
  <pre><code>            ImageFrame = new XamarinMobile.CustomRenderers.ExtendedFrame();
          FrameContainer = new Xamarin.Forms.AbsoluteLayout();
          ImageAndOverlayContainer = new Xamarin.Forms.AbsoluteLayout();
          ShowReadOverlay = new Xamarin.Forms.BoxView();
  
          headline = new Xamarin.Forms.Label();
          headline.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
          headline.HorizontalOptions = Xamarin.Forms.LayoutOptions.StartAndExpand;
          headline.TranslationX = 0;
          headline.TextColor = App.IsDarkThemeEnabled() ? Xamarin.Forms.Color.White : Xamarin.Forms.Color.Black;
          headline.FontSize = App.IsLargeTextEnabled() ? App.NormalizeFontSize(20) : App.NormalizeFontSize(16);
  
          loadingMoreStories = new Xamarin.Forms.Label();
          loadingMoreStories.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
          loadingMoreStories.HorizontalOptions = Xamarin.Forms.LayoutOptions.StartAndExpand;
          loadingMoreStories.TranslationX = 0;
          loadingMoreStories.TextColor = App.IsDarkThemeEnabled() ? Xamarin.Forms.Color.White : Xamarin.Forms.Color.Black;
          loadingMoreStories.FontSize = App.IsLargeTextEnabled() ? App.NormalizeFontSize(20) : App.NormalizeFontSize(16);
  
          publishDate = new Xamarin.Forms.Label();
          publishDate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
          publishDate.HorizontalOptions = Xamarin.Forms.LayoutOptions.StartAndExpand;
          publishDate.TranslationX = 0;
          publishDate.TextColor = App.IsDarkThemeEnabled() ? Xamarin.Forms.Color.White : Xamarin.Forms.Color.Gray;
          publishDate.FontSize = App.IsLargeTextEnabled() ? App.NormalizeFontSize(16) : App.NormalizeFontSize(12);
  
          cellImage = new Xamarin.Forms.Image();
          loadingText = new Xamarin.Forms.Label();
          loadingText.Text = "Loading...";
          loadingText.TextColor = App.IsDarkThemeEnabled() ? Xamarin.Forms.Color.White : Xamarin.Forms.Color.Gray;
          GoogleAdView = new Xamarin.Forms.ContentView();
          activityIndicator = new Xamarin.Forms.ActivityIndicator()
          {
              IsEnabled = false,
              IsRunning = false,
              Color = Xamarin.Forms.Color.Red
          };
          GoogleAd = new Controls.Ad();
          GoogleAdView.Content = GoogleAd;
          GoogleAd.AdFailed = (r) =&gt;
          {
  
          };
          GoogleAd.AdReturned = (r) =&gt;
          {
  
          };
  
          layout = new Xamarin.Forms.Grid();
          AdContainer = new Xamarin.Forms.Grid();
          LoadingLayout = new Xamarin.Forms.StackLayout()
          {
              VerticalOptions = Xamarin.Forms.LayoutOptions.Center,
              BackgroundColor = Xamarin.Forms.Color.Transparent,
              HorizontalOptions = App.Settings.SettingsValues.GridListView ? Xamarin.Forms.LayoutOptions.Start : Xamarin.Forms.LayoutOptions.Center,
              Orientation = Xamarin.Forms.StackOrientation.Vertical,
              Children =
              {
                  headline,
                  publishDate,
                  loadingMoreStories
              }
          };
          layout.RowDefinitions.Add(new Xamarin.Forms.RowDefinition { Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star) });
          layout.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition { Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star) });
          layout.Children.Add(loadingText, 0, 0);
  
          //Facebook Ads
          FacebookAdContainer = new Xamarin.Forms.StackLayout();
          FacebookAd = new Controls.FacebookAd();
          FacebookAd.PlacementId = $"{App.FacebookPlacementId}";
          FacebookAd.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
          FacebookAd.Page = MobileObjects.Enums.PageType.Grid;
          FacebookAdContainer.Children.Add(FacebookAd);
  
          AdContainer.Children.Add(GoogleAdView, 0, 0);
          AdContainer.Children.Add(FacebookAdContainer, 0, 0);
  
          layout.Children.Add(AdContainer, 0, 0);
          //ugh, we need to do an image frame because thats the only way (that I know of) to add a border on an image. We need this if the image is older than x, because they no longer have borders.
          ImageFrame.Padding = new Xamarin.Forms.Thickness(0);
          ShowReadOverlay.HeightRequest = 0;
          ImageAndOverlayContainer.Children.Add(cellImage);
          ImageAndOverlayContainer.Children.Add(ShowReadOverlay);
  
          ImageFrame.Content = ImageAndOverlayContainer;
          ImageFrame.HasShadow = false;
  
          FrameContainer.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
          FrameContainer.Children.Add(ImageFrame);
          layout.Children.Add(FrameContainer, 0, 0);
  
          layout.Children.Add(ShowReadOverlay, 0, 0);
          layout.Children.Add(LoadingLayout, 0, 0);
  
          loadingText.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
          loadingText.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
          cellImage.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
          cellImage.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
  
          if (!hasLoadedAdAtLeastOnce)
          {
              hasLoadedAdAtLeastOnce = true;
          }
  
          layout.Padding = new Xamarin.Forms.Thickness(App.HorizontalGridPadding);
          LoadingLayout.WidthRequest = 280;
          GoogleAdView.Content.HorizontalOptions = Xamarin.Forms.LayoutOptions.Center;
  
          View = layout;
  </code></pre>
  
  <p><strong>UPDATE 2 (How it's wired)</strong></p>
  
  <pre><code>foreach (MobileObjects.GridListStory story in stories.StoryList)
              {
                  index++;
  
                  //if (index % (adLocation + 1) == 0 &amp;&amp; index != stories.StoryList.Count)
                  if (index == _firstadlocation + 1)
                  {
                      PhoneCells.Add(new ViewModels.GridCellViewModel { Image = string.Empty, HasRead = false, Headline = "Loading Ad...", PublishDate = string.Empty, ActivityIndicator = new Xamarin.Forms.ActivityIndicator(), IsAd = true, ShowFacebookAd = App.Settings.SettingsValues.AdNetwork == MobileObjects.Enums.AdNetwork.facebook, rawCellIndex = index, collectionIndex = 0, numberOfStories = stories.StoryList.Count, LoadPageDate = LoadPageDate, StoryId = 0, IsEndOfGrid = IsEndOfGrid });
                      _numberOfAds++;
                  }
                  else
                  {
                      if (_subsequentadlocation != 0 &amp;&amp; index != _subsequentadlocation &amp;&amp; index != _firstadlocation &amp;&amp; ((index - (_firstadlocation)) % _subsequentadlocation == 0) &amp;&amp; (index != stories.StoryList.Count || index != stories.StoryList.Count - 1))
                      {
                          PhoneCells.Add(new ViewModels.GridCellViewModel { Image = string.Empty, HasRead = false, Headline = "Loading Ad...", PublishDate = string.Empty, ActivityIndicator = new Xamarin.Forms.ActivityIndicator(), IsAd = true, ShowFacebookAd = App.Settings.SettingsValues.AdNetwork == MobileObjects.Enums.AdNetwork.facebook, rawCellIndex = index, collectionIndex = 0, numberOfStories = stories.StoryList.Count, LoadPageDate = LoadPageDate, StoryId = 0, IsEndOfGrid = IsEndOfGrid });
                          _numberOfAds++;
                      }
                  }
  
                  try
                  {
                      ViewModels.GridCellViewModel newCell = new ViewModels.GridCellViewModel { Image = story.SquareImageURL, ImageWidth = story.SquareWidth, HasRead = story.ReadStory, Headline = story.Headline, PublishDate = story.AddedDateString, ActivityIndicator = new Xamarin.Forms.ActivityIndicator(), IsAd = false, rawCellIndex = index, collectionIndex = _index, numberOfStories = stories.StoryList.Count, LoadPageDate = LoadPageDate, StoryId = story.StoryId, IsEndOfGrid = IsEndOfGrid };
  
                      PhoneCells.Add(newCell);
  
                      //we could set these properties in the view model object above, but to make it easier to maintain, we're using a controller which will be the endpoint for any time we want to mark a story as read.
                      XamarinMobile.Controllers.SIRController.ChangeBGColor(story.ReadStory, PhoneCells[PhoneCells.Count - 1]);
                      XamarinMobile.Controllers.SIRController.ChangeTextColor(story.ReadStory, PhoneCells[PhoneCells.Count - 1]);
                  }
                  catch (System.Exception ex)
                  {
                      var j = ex;
                  }
                  _index++;
  
                  if (index == stories.StoryList.Count)
                  {
                      _lastStoryIdOfGrid = story.StoryId;
                  }
              }
              PhoneCells.Add(new ViewModels.GridCellViewModel { Image = string.Empty, HasRead = false, Headline = string.Empty, PublishDate = string.Empty, ActivityIndicator = new Xamarin.Forms.ActivityIndicator(), IsAd = false, collectionIndex = 0, rawCellIndex = stories.StoryList.Count + 1, numberOfStories = stories.StoryList.Count, LoadPageDate = LoadPageDate, StoryId = 0, IsEndOfGrid = IsEndOfGrid });
              SetUpGridNumberAndName();
              _navigatingToPage = false;
              Xamarin.Forms.Device.BeginInvokeOnMainThread(() =&gt;
              {
                  gridList.IsVisible = true;
                  gridList.ItemTemplate = new DataTemplate(typeof(Classes.CustomGridCell));
                  gridList.ItemsSource = PhoneCells;
                  App.GridCells = PhoneCells;
                  var adCells = PhoneCells.Where(x =&gt; x.IsAd);
                  if (adCells != null)
                  {
                      App.GridAdCells = new System.Collections.ObjectModel.ObservableCollection&lt;ViewModels.GridCellViewModel&gt;(adCells.ToList());
                  }
              });
  </code></pre>
  
  <p><strong>UPDATE 3 (GridCellViewModel)</strong></p>
  
  <pre><code> public class GridCellViewModel : System.ComponentModel.INotifyPropertyChanged
  {
      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  
      private Xamarin.Forms.Color _backgroundColor;
      public Xamarin.Forms.Color BackgroundColor
      {
          get { return _backgroundColor; }
          set
          {
              if(HasRead)
              {
                  _backgroundColor = value;
              } else
              {
                  _backgroundColor = Xamarin.Forms.Color.Transparent;
              }
  
              PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("BackgroundColor"));
          }
      }
  
      private Xamarin.Forms.Color _textColor;
      public Xamarin.Forms.Color TextColor
      {
          get { return _textColor; }
          set
          {
              if (HasRead)
              {
                  _textColor = value;
              }
              else
              {
                  if(App.IsDarkThemeEnabled())
                  {
                      _textColor = Xamarin.Forms.Color.White;
                  } else
                  {
                      _textColor = Xamarin.Forms.Color.Black;
                  }
              }
  
              PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("TextColor"));
          }
      }
      public string Image { get; set; }
      public string Headline { get; set; }
      public string PublishDate { get; set; }
      public Xamarin.Forms.ActivityIndicator ActivityIndicator { get; set; }
      public bool IsAd { get; set; }
  
      public bool HasRead { get; set; }
      public bool AdHasLoaded { get; set; } = false;
      public int collectionIndex { get; set; }
      public int rawCellIndex { get; set; }
      public int numberOfStories { get; set; }
      public DateTime LoadPageDate { get; set; }
      public int StoryId { get; set; }
      public bool IsEndOfGrid { get; set; }
      //next 2 properties only used for tablets
      public int ImageWidth { get; set; }
      public int ImageHeight { get; set; }
  
      private Guid _adIdentification = Guid.NewGuid();
      public Guid AdIdentification
      {
          get
          {
              return _adIdentification;
          }
      }
  
      private MobileObjects.Enums.AdNetwork _adNetwork;
  
      public MobileObjects.Enums.AdNetwork AdNetwork
      {
          get
          {
              return App.Settings.SettingsValues.AdNetwork;
          }
      }
  
      private bool _showFacebookAd = true;
      public bool ShowFacebookAd
      {
          get { return _showFacebookAd; }
          set
          {
              _showFacebookAd = value;
              PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("ShowFacebookAd"));
          }
      }
  
      private bool _showGoogleAd = false;
      public bool ShowGoogleAd
      {
          get { return _showGoogleAd; }
          set
          {
              if (value == true)
              {
                  //attempt to load ad???
              }
  
              _showGoogleAd = value;
              PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("ShowGoogleAd"));
          }
      }
  </code></pre>