CarouselView by AlexRainman is not iOS, works great on Android. Xamarin.Forms

I am having trouble customizing the AlexRainman CarouselView control . The control works fine on Android, but not on iOS. My project is a Xamarin PCL project for iOS and Android that is 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>

      

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; }
    }
}

      

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());
    }
}

      

+3


source to share


2 answers


If control CarouselView from AlexRainman tryout carouselview



https://github.com/pateljay0323/CarouselLayout

0


source


My problem might not be what you have, but this is how I solved it: it worked fine on CarouselView.FormsPlugin 4.4.1 and Xamarin forms 2.3 ... works great, updates carousel view to 4.4.3 iOS breaks Android works great, I posted a question on github and seems to have solved it, so try updating to the latest version and xamarin formats to 2.4.0 should work. here is the github question: https://github.com/alexrainman/CarouselView/issues/210



0


source







All Articles