I'm having trouble making the CarouselView control from AlexRainman. The control is rendered fine on Android, but not on iOS. My project is a Xamarin PCL project for iOS and Android, currently working on Visual Studio 2017 for macOS. And stuck on this, and have no idea how to solve this error. Any help would be appreciated.
My Content Page:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PelotaJara.BookingUserPage"
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
>
<controls:CarouselViewControl x:Name="carousel" IndicatorsTintColor="Gray" ShowIndicators="True"
CurrentPageIndicatorTintColor="Black" Orientation="Horizontal" InterPageSpacing="10"
VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" AnimateTransition="true" IsSwipingEnabled="true">
<controls:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30*" />
<RowDefinition Height="50*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>
<Image Grid.Row="0" VerticalOptions="Start" HorizontalOptions="CenterAndExpand" Source="{Binding Image}"/>
<Label Grid.Row="0" Text="Cancha Iluminada" TextColor="White" HorizontalOptions="Center" VerticalOptions="End"/>
<Button Grid.Row="2" Text="Reservar" BackgroundColor="Red" HorizontalOptions="Fill" VerticalOptions="Center" TextColor="White"/>
</Grid>
</DataTemplate>
</controls:CarouselViewControl.ItemTemplate>
</controls:CarouselViewControl>
The Code-behind:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class BookingUserPage : ContentPage
{
ObservableCollection<CarouselModel> model { get; set; }
public BookingUserPage()
{
InitializeComponent();
model = new ObservableCollection<CarouselModel>();
carousel.ItemsSource = model;
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
}
}
public class CarouselModel
{
public CarouselModel(string imageString)
{
Image = imageString;
}
private string _image;
public string Image
{
get { return _image; }
set { _image = value; }
}
}
The Appdelegate.cs:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
CarouselViewRenderer.Init();
return base.FinishedLaunching(app, options);
}
And finally, my MainActivity.cs:
[Activity(Label = "PelotaJara", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
CarouselViewRenderer.Init();
LoadApplication(new App());
}
}