)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add the scrollbar to the Carousel items?

Platform: WPF |
Control: Carousel |
Published Date: July 13, 2018 |
Last Revised Date: June 25, 2019

User can add the ScrollBar to the Carousel Items. It can be achieved by adding the ScrollViewer control inside the ItemTemplate of Carousel control. The following code demonstrates the same.

 

XAML

<Window.DataContext>
 
<local:ViewModel/>
 
</Window.DataContext>
 
<!-- Carousel control -->
 
<syncfusion:Carousel Height="300" x:Name="carousel" ItemsSource="{Binding Collection}">
 
<!-- Set Height For Carousel Items -->
 
<syncfusion:Carousel.ItemContainerStyle>
 
<Style TargetType="syncfusion:CarouselItem">
 
<Setter Property="Height" Value="140" />
 
</Style>
 
</syncfusion:Carousel.ItemContainerStyle>
 
<!-- For Adding ScrollBar to Carousel Items -->
 
<syncfusion:Carousel.ItemTemplate>
 
<DataTemplate>
 
<Grid >
 
<!-- Add ScrollBar  -->
 
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
 
<Border x:Name="border" >
 
<Grid Width="150" Height="300">
 
<Grid.RowDefinitions>
 
<RowDefinition Height="Auto" />
 
<RowDefinition Height="Auto" />
 
</Grid.RowDefinitions>
 
<TextBox TextWrapping="Wrap" Grid.Row="0"  Background="Green" Foreground="White" 
 
Text="The Carousel is a circular conveyor used on which objects are displayed and rotated. The Carousel control provides a 3D interface for displaying objects with interactive navigation, Data Binding Path, Items Per Page, Scaling and Skewing."/>
 
<Image Source="/Images1/dodsworth.png" Grid.Row="1"  />
 
</Grid>
 
</Border>
 
</ScrollViewer>
 
</Grid>
 
</DataTemplate>
</syncfusion:Carousel.ItemTemplate>

 

C#

public class Model
{
 
 
}
 
public ObservableCollection<Model> Collection { get; set; }
 
public ViewModel()
{
 
Collection = new ObservableCollection<Model>();
 
Collection.Add(new Model() );
 
Collection.Add(new Model() );
 
Collection.Add(new Model() );
 
Collection.Add(new Model() );
 
Collection.Add(new Model() );          
 
}

 

Screenshot

Carousel.png

 

Sample:  CarouselSample

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon