locked
Using CarouselView like CarouselPage RRS feed

  • Question

  • User369520 posted

    I'm trying to populate a Carouselview with Scrollviews and nothing renders. I know the scrollview has content as it renders when I said it as the content for the contentpage. PageScrollView subclasses Scrollview.

    I have tried using Images instead of Scrollview and it renders just fine. Am I missing something?

    private void generateLayout()
            {
    
    
                    using (var vRealmDb = Realm.GetInstance(App.realmConfiguration))
                    {
    
                        foreach (var formPage in currentForm.pages)
                        {
    
                        var layout = new RelativeLayout();
    
                        Image image =null;
    
                            if (formPage.image != null)
                            {
                            ImageSource imageSource = null;
                            Stream stream = new MemoryStream(formPage.image);
    
                                imageSource = ImageSource.FromStream(() => stream);
                                image = new Image
                                {
                                    Aspect = Aspect.Fill,
                                    Source = imageSource
    
                                };
    
    
    
    
    
    
                            layout.Children.Add(image,
            Constraint.Constant(0),
            Constraint.Constant(0),
            Constraint.RelativeToParent((parent) => { return parent.Width; }),
            Constraint.RelativeToParent((parent) => { return parent.Height; }));
    
                        }
    
    
    
                        addControls(layout,image, formPage);
    
                        PageScrollView sv = new PageScrollView();
    
    
    
    
                        var zoomable = new PinchToZoomContainer();
                        zoomable.Content = layout;
                        zoomable.HeightRequest = scrollHeight;
    
    
                        sv.Content = zoomable;
                        sv.PageNo = formPage.pageNo;
    
                        sv.HorizontalOptions = LayoutOptions.FillAndExpand;
                        sv.VerticalOptions = LayoutOptions.FillAndExpand;
    
                        pages.Add(sv);
    
    
                    }
    
                    CarouselView cv = new CarouselView { ItemsSource = pages, ItemTemplate = GetDataTemplate(),HorizontalOptions= LayoutOptions.FillAndExpand
                    ,VerticalOptions= LayoutOptions.FillAndExpand
                    };
    
    
                    Content = cv;
    
                }
    
    
    
    
    
            }
    
            public DataTemplate GetDataTemplate()
            {
                return new DataTemplate(() =>
                {
                    PageScrollView v = pages[Count];
                    Count++;
                    return v;
                });
            }
    
    Wednesday, June 12, 2019 1:00 PM

Answers

  • User372631 posted

    You can use the nuget package CarouselView.FormsPlugin .Refer to https://github.com/alexrainman/CarouselView <controls:CarouselViewControl Orientation="Horizontal" InterPageSpacing="10" Position="{Binding myPosition}" ItemsSource="{Binding myItemsSource}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <controls:CarouselViewControl.ItemTemplate> <DataTemplate> //... </DataTemplate> </controls:CarouselViewControl.ItemTemplate> </controls:CarouselViewControl>

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 13, 2019 1:52 AM

All replies

  • User372631 posted

    You can use the nuget package CarouselView.FormsPlugin .Refer to https://github.com/alexrainman/CarouselView <controls:CarouselViewControl Orientation="Horizontal" InterPageSpacing="10" Position="{Binding myPosition}" ItemsSource="{Binding myItemsSource}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <controls:CarouselViewControl.ItemTemplate> <DataTemplate> //... </DataTemplate> </controls:CarouselViewControl.ItemTemplate> </controls:CarouselViewControl>

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 13, 2019 1:52 AM
  • User369520 posted

    Thanks for that. So just swapping in that control worked perfectly first time.

    So the XF4 CarouselView is broken i guess.

    I've only been working on a XF project for a few days and getting frustrated with stuff just not working properly. End of moan.

    Thanks again.

    Thursday, June 13, 2019 3:22 PM