Hide a specific child page of a CarouselPage

ManishPradhanManishPradhan Member
edited December 2018 in Xamarin.Forms

Hi Guys,

I need a way to hide a specific carousel page. I do not want to remove the page as a whole because then I would lose all the changes made on that particular page which I want to maintain like Field changes, Scroll position, control states and so on. Possible? I dont mind using TabbedPage is this feature is only possible on that.

Thanks.

Best Answer

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    I think you can’t. You can take a look to new CollectionView...
  • NicolasKrierNicolasKrier FRMember ✭✭✭

    Hello,
    I don't think it's possible. Maybe with custom renderers ? If you ever find something, could you update this thread please ?
    I wish you luck !

  • @LandLu said:
    Firstly define your own CarouselPage class, make this particular content page as a field of it. Then you can use the same instance when you want to remove and add it. This will not lose the previous settings you have configured on it. Here is my Carousel Page for you referring to:

    public class MyCarouselPage : CarouselPage
    {
        ContentPage particularPage;
        public MyCarouselPage()
        {
            ...
            // Initialize the particularPage and add it here.
            // Also add other children you want to use in the CarouselPage
        }
    
        // Define a remove method
        public void Remove()
        {
            if (Children.IndexOf(particularPage) != -1)
            {
                Children.Remove(particularPage);
            }
        }
    
        // Modify the index as you want
        public void Add()
        {
            if (Children.IndexOf(particularPage) == -1)
            {
                Children.Insert(0, particularPage);
            }          
        }
    }
    

    Thanks, I just tried as you suggested and I think there is hope here. I can remove the page and when I add it back I can see that things are maintained Except for the scroll position which I can take care of manually I guess. I havent tested everything on the page and if I find anything I will post back. Thanks again guys.

Sign In or Register to comment.