Loading...
Loading...
Implements the Syncfusion WPF Carousel for displaying items in rotating or custom path interfaces with navigation support. Use when building image carousels, rotating galleries, or custom-path item displays with templates and data binding.
npx skill4agent add syncfusion/wpf-ui-components-skills syncfusion-wpf-carousel<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<syncfusion:Carousel Name="carousel"
Height="400"
Width="600"
ItemsSource="{Binding Items}">
<syncfusion:Carousel.ItemTemplate>
<DataTemplate>
<Border Height="100"
Width="150"
BorderBrush="Purple"
BorderThickness="3"
Background="LightBlue"
CornerRadius="5">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image Source="{Binding ImageSource}"
Height="60"
Width="80"/>
<TextBlock Text="{Binding Name}"
FontWeight="Bold"
Margin="0,5,0,0"/>
</StackPanel>
</Border>
</DataTemplate>
</syncfusion:Carousel.ItemTemplate>
</syncfusion:Carousel>
</Window>using Syncfusion.Windows.Shared;
using System.Collections.ObjectModel;
// ViewModel
public class ViewModel
{
public ObservableCollection<CarouselItem> Items { get; set; }
public ViewModel()
{
Items = new ObservableCollection<CarouselItem>
{
new CarouselItem { Name = "Item 1", ImageSource = "/Images/img1.png" },
new CarouselItem { Name = "Item 2", ImageSource = "/Images/img2.png" },
new CarouselItem { Name = "Item 3", ImageSource = "/Images/img3.png" }
};
}
}
// Model
public class CarouselItem
{
public string Name { get; set; }
public string ImageSource { get; set; }
}<syncfusion:Carousel ItemsSource="{Binding Products}"
ScaleFraction="0.7"
ScalingEnabled="True"
OpacityFraction="0.5"
OpacityEnabled="True"
RotationSpeed="300">
<syncfusion:Carousel.ItemTemplate>
<DataTemplate>
<Border Height="120" Width="150"
Background="White"
BorderBrush="Gray"
BorderThickness="2">
<Grid>
<Image Source="{Binding ProductImage}" Stretch="Uniform"/>
<TextBlock Text="{Binding ProductName}"
VerticalAlignment="Bottom"
Background="#CC000000"
Foreground="White"
Padding="5"/>
</Grid>
</Border>
</DataTemplate>
</syncfusion:Carousel.ItemTemplate>
</syncfusion:Carousel><syncfusion:Carousel VisualMode="CustomPath"
ItemsPerPage="5"
ItemsSource="{Binding Gallery}"
ScaleFraction="0.8"
OpacityFraction="0.3">
<syncfusion:Carousel.Path>
<Path Data="M0,100 L500,100"
Stroke="Blue"
StrokeThickness="2"/>
</syncfusion:Carousel.Path>
<syncfusion:Carousel.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}"
Height="100"
Width="100"
Stretch="UniformToFill"/>
</DataTemplate>
</syncfusion:Carousel.ItemTemplate>
</syncfusion:Carousel>// Navigate to specific items
carousel.SelectFirstItem();
carousel.SelectLastItem();
carousel.SelectNextItem();
carousel.SelectPreviousItem();
// Navigate by pages
carousel.SelectNextPage();
carousel.SelectPreviousPage();
// Set selected item programmatically
carousel.SelectedIndex = 2;
// Using commands in XAML
<Button Content="Next"
Command="{Binding ElementName=carousel, Path=SelectNextItemCommand}"/>
<Button Content="Previous"
Command="{Binding ElementName=carousel, Path=SelectPreviousItemCommand}"/>carousel.SelectionChanged += Carousel_SelectionChanged;
private void Carousel_SelectionChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var oldItem = e.OldValue;
var newItem = e.NewValue;
// Get selected item details
var selectedIndex = carousel.SelectedIndex;
var selectedItem = carousel.SelectedItem;
var selectedValue = carousel.SelectedValue;
// Perform actions based on selection
Debug.WriteLine($"Selected: {selectedItem}");
}<syncfusion:Carousel VisualMode="CustomPath"
ScalingEnabled="True"
OpacityEnabled="True"
ItemsSource="{Binding Items}">
<syncfusion:Carousel.Path>
<Path Data="M0,0 Q250,200 500,0"
Stroke="Red"
StrokeThickness="1"/>
</syncfusion:Carousel.Path>
<!-- Individual scaling per position -->
<syncfusion:Carousel.ScaleFractions>
<syncfusion:PathFractionCollection>
<syncfusion:FractionValue Fraction="0" Value="0.5"/>
<syncfusion:FractionValue Fraction="0.5" Value="1.0"/>
<syncfusion:FractionValue Fraction="1" Value="0.5"/>
</syncfusion:PathFractionCollection>
</syncfusion:Carousel.ScaleFractions>
<!-- Individual opacity per position -->
<syncfusion:Carousel.OpacityFractions>
<syncfusion:PathFractionCollection>
<syncfusion:FractionValue Fraction="0" Value="0.3"/>
<syncfusion:FractionValue Fraction="0.5" Value="1.0"/>
<syncfusion:FractionValue Fraction="1" Value="0.3"/>
</syncfusion:PathFractionCollection>
</syncfusion:Carousel.OpacityFractions>
</syncfusion:Carousel>| Property | Description | Default |
|---|---|---|
| Display mode: | |
| Collection to bind carousel items | |
| Index of selected item | |
| Currently selected item object | |
| Horizontal radius (Standard mode) | |
| Vertical radius (Standard mode) | |
| Animation speed in milliseconds | |
| Scale factor for non-selected items (0-1) | |
| Enable/disable scaling effects | |
| Opacity for non-selected items (0-1) | |
| Enable/disable opacity effects | |
| Items visible per page (CustomPath only) | |
| Loop items in CustomPath mode | |
| Enable UI virtualization for performance | |
| Custom path geometry for CustomPath mode | |