Example #1
0
 private void UpdateAdapter()
 {
     Context.InvokeOnMainThread(() =>
     {
         _adapter = new CarouselAdapter(Element);
         Control.SetAdapter(_adapter);
         UpdateCurrent(false);
     });
 }
Example #2
0
        private void CreateCarousel(Carousel element)
        {
            //Create carousel
            var carousel = new SnappyRecyclerView(Xamarin.Forms.Forms.Context, SelectItemAction);

            //Setup layout options
            var frame  = element.Bounds;
            var width  = (int)Context.ToPixels(frame.Width);
            var height = (int)Context.ToPixels(frame.Height);

            carousel.LayoutParameters = new LayoutParams(width, height);

            //Set the custom adapter
            _adapter = new CarouselAdapter(element);
            carousel.SetAdapter(_adapter);

            //Set the custom layout manager
            _layoutManager = new SnappyLinearLayoutManager(Context);
            carousel.SetLayoutManager(_layoutManager);

            SetNativeControl(carousel);
        }