Skip to content

Instantly share code, notes, and snippets.

@darthdeus
Created September 9, 2014 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darthdeus/af0f11b0e5c306bfc134 to your computer and use it in GitHub Desktop.
Save darthdeus/af0f11b0e5c306bfc134 to your computer and use it in GitHub Desktop.
using System;
using Xamarin.Forms;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace ListViewLayoutBug
{
public class TestPage : ContentPage
{
public TestPage()
{
var source = new ObservableCollection<string>();
var list = new ListView
{
// Comment this line out to observe the bug. It's just here to show that the asynchronous
// loading itself works.
HeightRequest = 80,
ItemsSource = source
};
LoadItems(source);
var layout = new AbsoluteLayout();
layout.Children.Add(list);
Content = layout;
}
async void LoadItems(ObservableCollection<string> items)
{
// If you comment the delay out, the function will run synchronously and the content will appear.
await Task.Delay(2000);
items.Add("hello");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment