Disable Carousel Item

2 posts, 0 answers
  1. Robert
    Robert avatar
    3 posts
    Member since:
    Dec 2015

    Posted 27 Jan Link to this post

    Just curious if there is any way to disable a carousel item. I do not wish to remove the item, but rather have it still display, but  not able to be selected and be skipped over when one of the scroll buttons is pressed. Is there any way to do this?
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    281 posts

    Posted 01 Feb Link to this post

    Hi Robert,

    You can achieve the desired effect by changing the predefined scroll buttons for the RadCarousel, as explained in the following article - Change the Predefined Scroll Buttons. I have created a sample project that implements the logic for the required behavior. In my case, as the DataContext consists of several Employee objects, I would like to skip the item for "Laura". 

    You can check what is the top-most item through the TopContainer property of the RadCarousel Panel. Here is the approach:

    private void pageLeftButton_Click(object sender, RoutedEventArgs e)
            {
                
                var panel = this.RadCarousel1.FindCarouselPanel() as RadCarouselPanel;
                var topMostItem = panel.TopContainer as CarouselItem;
     
                if ((topMostItem.DataContext as Employee).FirstName != "Anne")
                {
                    this.RadCarousel1.FindCarouselPanel().MoveBy(-1);
                }
                else
                {
                    this.RadCarousel1.FindCarouselPanel().MoveBy(-2);
                }
            }

     private void pageRightButton_Click(object sender, RoutedEventArgs e)
            {
                var panel = this.RadCarousel1.FindCarouselPanel() as RadCarouselPanel;
                var topMostItem = panel.TopContainer as CarouselItem;
                 
                if ((topMostItem.DataContext as Employee).FirstName != "Robert" )
                {
                    this.RadCarousel1.FindCarouselPanel().MoveBy(1);
                }
                else
                {
                    this.RadCarousel1.FindCarouselPanel().MoveBy(2);
                }
            }

    Please update me if the information provided was useful.

    Regards,
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top