maui-linux/Xamarin.Forms.Sandbox/App.cs

68 строки
1.6 KiB
C#
Исходник Обычный вид История

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<String>(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<iOS>().SetUseSafeArea(true);
return returnValue;
}
ContentPage CreateListViewPage(Func<View> 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<View> 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<View> children)
{
return CreateContentPage(CreateStackLayout(children));
}
}
}