using System; using System.Collections.Generic; using System.Linq; using Xamarin.Forms; using Xamarin.Forms.Xaml; using Xamarin.Forms.PlatformConfiguration.iOSSpecific; using Xamarin.Forms.PlatformConfiguration; [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace Xamarin.Forms.Sandbox { public partial class App : Application { public App() { Device.SetFlags(new[] { "Shell_Experimental", "CollectionView_Experimental" }); InitializeMainPage(); } void InitializeFastRenderers() { var flags = new List(Device.Flags); flags.Add("FastRenderers_Experimental"); Device.SetFlags(flags.Select(x => x).Distinct().ToArray()); } ContentPage CreateContentPage(View view) { var returnValue = new ContentPage() { Content = view }; returnValue.On().SetUseSafeArea(true); return returnValue; } ContentPage CreateListViewPage(Func template) { var listView = new ListView(ListViewCachingStrategy.RecycleElement); listView.RowHeight = 500; listView.ItemsSource = Enumerable.Range(0, 1).ToList(); listView.ItemTemplate = new DataTemplate(() => { ViewCell cell = new ViewCell(); cell.View = template(); return cell; }); return CreateContentPage(listView); } StackLayout CreateStackLayout(IEnumerable children, StackOrientation orientation = StackOrientation.Vertical ) { var sl = new StackLayout() { Orientation = orientation }; foreach (var child in children) sl.Children.Add(child); return sl; } ContentPage CreateStackLayoutPage(IEnumerable children) { return CreateContentPage(CreateStackLayout(children)); } } }