Get the child views for the SfCarousel similar to the built-in MAUI Carousel VisibleViews

Is there a way to get the child views for the SfCarousel, similar to how you can use VisibleViews to get the child views for the built-in MAUI Carousel?

The reason I am asking is because my carousel items include a ScrollView, which I would like to be able to programmatically scroll based on certain conditions. Using the built-in MAUI Carousel, I am able to access the ScrollView of interest like this:

var scrollView = carouselViewDays.VisibleViews?.FirstOrDefault(v => v.BindingContext == day)?.GetVisualTreeDescendants().OfType<ScrollView>().FirstOrDefault(s => s.IsVisible);

However, I haven't been able to figure out a way to get the scrollview using the Syncfusion carousel. The scrollview is part of the ItemTemplate for the carousel.


3 Replies

KP Kamalesh Periyasamy Syncfusion Team February 12, 2025 01:12 PM UTC

Hi Andy Kannenberg, 
 
Thank you for reaching out regarding retrieving the ScrollView from the ItemTemplate in the SfCarousel, similar to how it can be done in the built-in MAUI CarouselView using VisibleViews. 
 
After reviewing your query, we would like to inform you that, currently, it is not possible to directly retrieve inner views, such as the ScrollView, within the ItemTemplate of the SfCarousel. We are also actively exploring possible ways to retrieve inner views using existing properties. 
 
To help us better understand your use case, could you kindly provide more details about the functionality you are trying to implement with retrieving the inner view? This will assist us in exploring potential solutions for your specific scenario. 
 
We appreciate your understanding and look forward to hearing more about your requirements. 
 
Regards, 
Kamalesh P 



AK Andy Kannenberg February 12, 2025 04:27 PM UTC

Sure, here's a simplified example of what I am currently doing using the built-in MAUI carousel:

Carousel.xaml:


        <CarouselView x:Name="carouselView"

                      CurrentItem="{Binding SelectedItem}"

                      CurrentItemChanged="carouselView_CurrentItemChanged"

                      ItemsSource="{Binding Items}">

            <CarouselView.ItemTemplate>

                <DataTemplate>

                        <ScrollView x:Name="scrollView">

                            <!--Content longer than the screen height goes here-->

                        </ScrollView>

                </DataTemplate>

            </CarouselView.ItemTemplate>

        </CarouselView>


Carousel.xaml.cs:


        public async Task ScrollToItemAsync(Item item)

        {

            var scrollView = carouselViewDays.VisibleViews?.FirstOrDefault(v => v.BindingContext == item)?.GetVisualTreeDescendants().OfType<ScrollView>().FirstOrDefault(s => s.IsVisible);


            if (scrollView != null)

            {

                var element = scrollView.GetVisualTreeDescendants().OfType</*ItemOfInterest*/>().FirstOrDefault();


                if (element != null)

                     await scrollView.ScrollToAsync((Element)element, ScrollToPosition.Start, true);

            }

        }



This works fine using the built-in MAUI carousel; however, I would prefer to replace it with the Syncfusion carousel because the built-in MAUI carousel control is quite buggy, especially on Windows. Unfortunately, without the ability to programmatically scroll the ScrollView in the carousel ItemTemplate with the Syncfusion carousel, it appears that I am stuck with the built-in MAUI carousel at this time.  





KP Kamalesh Periyasamy Syncfusion Team February 13, 2025 02:21 PM UTC

Hi Andy, 
 
Thank you for reaching out and for sharing your use case in detail. After reviewing the possibilities, we regret to inform you that, at this time, SfCarousel does not provide a way to programmatically access and scroll inner views, such as ScrollView, within the ItemTemplate. Unlike the built-in MAUI CarouselView, which exposes VisibleViews, SfCarousel does not currently support a similar API to retrieve the rendered child views. 
 
We understand that this functionality is important for your implementation, and we appreciate your feedback. Our team is actively exploring potential enhancements to improve flexibility in future updates. In the meantime, if there's anything else we can assist you with, please let us know. 

 
Regards, 
Kamalesh P 


Loader.
Up arrow icon