syncfusion-winforms-carousel

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Syncfusion WinForms Carousel Control

Syncfusion WinForms Carousel 控件

The Carousel control is a circular conveyor that displays and rotates objects in a 3D interface. It provides interactive navigation for images, custom controls, and various carousel path options for creating engaging visual displays.
Carousel 控件是一种圆形传送带组件,可在3D界面中展示和旋转对象。它为图片、自定义控件提供交互式导航功能,还支持多种轮播路径选项,可用于创建极具吸引力的视觉展示效果。

When to Use This Skill

什么时候使用该组件

Use the Carousel control when you need to:
  • Create interactive 3D image galleries or product showcases
  • Display rotating panels with custom controls
  • Implement circular navigation for items or images
  • Build image slide shows with carousel effects
  • Create product viewers with multiple angle displays
  • Implement touch-enabled rotating interfaces
  • Design orbital or linear item arrangements
  • Build visual dashboards with rotating components
  • Create engaging UI presentations with 3D effects
当你需要实现以下需求时可以使用Carousel控件:
  • 创建交互式3D图片画廊或产品展示柜
  • 展示带有自定义控件的旋转面板
  • 为物品或图片实现圆形导航效果
  • 构建带有轮播特效的图片幻灯片
  • 创建支持多视角展示的产品查看器
  • 实现支持触摸操作的旋转界面
  • 设计轨道式或线性的物品排列布局
  • 构建带有旋转组件的可视化仪表盘
  • 创建带有3D特效的引人注目的UI展示

Installation

安装

NuGet Installation

NuGet 安装

bash
Install-Package Syncfusion.Tools.Windows
bash
Install-Package Syncfusion.Tools.Windows

Assembly References

程序集引用

Add references to:
  • Syncfusion.Grid.Base
  • Syncfusion.Grid.Windows
  • Syncfusion.Shared.Base
  • Syncfusion.Shared.Windows
  • Syncfusion.Tools.Base
  • Syncfusion.Tools.Windows
添加以下程序集的引用:
  • Syncfusion.Grid.Base
  • Syncfusion.Grid.Windows
  • Syncfusion.Shared.Base
  • Syncfusion.Shared.Windows
  • Syncfusion.Tools.Base
  • Syncfusion.Tools.Windows

Quick Start

快速入门

Basic Carousel with Custom Controls

搭载自定义控件的基础轮播

csharp
using System;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;

namespace CarouselDemo
{
    public partial class Form1 : Form
    {
        private Carousel carousel1;
        
        public Form1()
        {
            InitializeComponent();
            
            // Create Carousel
            carousel1 = new Carousel();
            carousel1.Size = new System.Drawing.Size(600, 400);
            carousel1.Location = new System.Drawing.Point(50, 50);
            
            // Create custom controls (e.g., buttons)
            for (int i = 1; i <= 6; i++)
            {
                ButtonAdv button = new ButtonAdv();
                button.Text = "Item " + i;
                button.Size = new System.Drawing.Size(100, 80);
                button.BackColor = System.Drawing.Color.FromArgb(22, 165, 220);
                button.ForeColor = System.Drawing.Color.White;
                
                // Add to both Controls and Items collections
                carousel1.Controls.Add(button);
                carousel1.Items.Add(button);
            }
            
            // Add to form
            this.Controls.Add(carousel1);
        }
    }
}
csharp
using System;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;

namespace CarouselDemo
{
    public partial class Form1 : Form
    {
        private Carousel carousel1;
        
        public Form1()
        {
            InitializeComponent();
            
            // Create Carousel
            carousel1 = new Carousel();
            carousel1.Size = new System.Drawing.Size(600, 400);
            carousel1.Location = new System.Drawing.Point(50, 50);
            
            // Create custom controls (e.g., buttons)
            for (int i = 1; i <= 6; i++)
            {
                ButtonAdv button = new ButtonAdv();
                button.Text = "Item " + i;
                button.Size = new System.Drawing.Size(100, 80);
                button.BackColor = System.Drawing.Color.FromArgb(22, 165, 220);
                button.ForeColor = System.Drawing.Color.White;
                
                // Add to both Controls and Items collections
                carousel1.Controls.Add(button);
                carousel1.Items.Add(button);
            }
            
            // Add to form
            this.Controls.Add(carousel1);
        }
    }
}

Basic Carousel with Images

搭载图片的基础轮播

csharp
using Syncfusion.Windows.Forms.Tools;

// Enable image slides
carousel1.ImageSlides = true;

// Create and add images
for (int i = 1; i <= 6; i++)
{
    CarouselImage carouselImage = new CarouselImage();
    carouselImage.ItemImage = Image.FromFile($"Images/image{i}.png");
    
    carousel1.ImageListCollection.Add(carouselImage);
}
csharp
using Syncfusion.Windows.Forms.Tools;

// Enable image slides
carousel1.ImageSlides = true;

// Create and add images
for (int i = 1; i <= 6; i++)
{
    CarouselImage carouselImage = new CarouselImage();
    carouselImage.ItemImage = Image.FromFile($"Images/image{i}.png");
    
    carousel1.ImageListCollection.Add(carouselImage);
}

Core Concepts

核心概念

Carousel Paths

轮播路径

The control supports multiple path arrangements: Default (elliptical), Orbital, Oval, and Linear. Each path provides different visual layouts for items.
该控件支持多种路径排列方式:默认(椭圆)、轨道、椭圆形、线性。每种路径都能为物品提供不同的视觉布局。

Image Slides Mode

图片轮播模式

Enable
ImageSlides = true
to work specifically with images. Images can be added via
ImageListCollection
,
ImageList
property, or
FilePath
property.
开启
ImageSlides = true
即可专门用于图片展示场景。你可以通过
ImageListCollection
ImageList
属性或者
FilePath
属性添加图片。

Custom Controls

自定义控件

Any WinForms control can be added to the carousel. Controls must be added to both
Controls
and
Items
collections.
任何WinForms控件都可以添加到轮播中,控件必须同时添加到
Controls
Items
集合中。

Perspective and Speed

透视效果与速度

Control the visual depth with
Perspective
property and rotation speed with
TransitionSpeed
property.
通过
Perspective
属性控制视觉深度,通过
TransitionSpeed
属性控制旋转速度。

Touch Interactions

触摸交互

The carousel responds to touch gestures: pan/flick for rotation, pinch/stretch for perspective adjustments.
轮播组件支持触摸手势响应:平移/轻划实现旋转,捏合/拉伸调整透视效果。

Navigation Guide

使用导航

🚀 Getting Started

🚀 入门指南

📄 Read: references/getting-started.md
  • Assembly deployment and dependencies
  • Adding Carousel via Designer
  • Adding Carousel via code
  • Adding custom controls to carousel
  • Adding images to carousel
  • Initial setup and configuration
📄 阅读: references/getting-started.md
  • 程序集部署与依赖项
  • 通过设计器添加Carousel控件
  • 通过代码添加Carousel控件
  • 向轮播中添加自定义控件
  • 向轮播中添加图片
  • 初始化设置与配置

🛤️ Carousel Paths

🛤️ 轮播路径

📄 Read: references/carousel-paths.md
  • Default (elliptical) path
  • Orbital path layout
  • Oval path layout
  • Linear path arrangement
  • Choosing the right path for your scenario
  • Path property configuration
📄 阅读: references/carousel-paths.md
  • 默认(椭圆)路径
  • 轨道路径布局
  • 椭圆形路径布局
  • 线性路径排列
  • 为你的场景选择合适的路径
  • 路径属性配置

🖼️ Image Slides

🖼️ 图片轮播

📄 Read: references/image-slides.md
  • Enabling ImageSlides mode
  • Adding images via ImageListCollection
  • Adding images via ImageList property
  • Adding images via FilePath property
  • CarouselImage class usage
  • Image management best practices
📄 阅读: references/image-slides.md
  • 开启图片轮播模式
  • 通过ImageListCollection添加图片
  • 通过ImageList属性添加图片
  • 通过FilePath属性添加图片
  • CarouselImage类使用方法
  • 图片管理最佳实践

🎨 Visual Configuration

🎨 视觉配置

📄 Read: references/visual-configuration.md
  • Perspective property (zoom control)
  • TransitionSpeed property (rotation speed)
  • ShowImageShadow property
  • ShowImagePreview property
  • ImageHighlightColor property
  • ImageShadeColor property
  • Combining visual effects
📄 阅读: references/visual-configuration.md
  • Perspective属性(缩放控制)
  • TransitionSpeed属性(旋转速度)
  • ShowImageShadow属性
  • ShowImagePreview属性
  • ImageHighlightColor属性
  • ImageShadeColor属性
  • 视觉效果组合使用

🔄 Rotation Behavior

🔄 旋转行为

📄 Read: references/rotation-behavior.md
  • RotateAlways property for continuous rotation
  • Auto-play configuration
  • Controlling rotation programmatically
  • Stopping and starting rotation
📄 阅读: references/rotation-behavior.md
  • 用于持续旋转的RotateAlways属性
  • 自动播放配置
  • 通过代码控制旋转
  • 停止与启动旋转

👆 Touch Interactions

👆 触摸交互

📄 Read: references/touch-interactions.md
  • Touch support overview
  • Pan and flick gestures for rotation
  • Pinch and stretch for perspective control
  • Touch vs mouse interactions
📄 阅读: references/touch-interactions.md
  • 触摸支持概述
  • 平移和轻划手势控制旋转
  • 捏合和拉伸控制透视效果
  • 触摸与鼠标交互的区别

Common Patterns

常用场景示例

Pattern 1: Product Image Gallery

示例1:产品图片画廊

csharp
// Create image-based carousel for product showcase
Carousel productCarousel = new Carousel();
productCarousel.ImageSlides = true;
productCarousel.CarouselPath = CarouselPath.Default;
productCarousel.Perspective = 4.5f;
productCarousel.TransitionSpeed = 2.0f;
productCarousel.ShowImagePreview = true;
productCarousel.ShowImageShadow = true;

// Add product images
foreach (string imagePath in Directory.GetFiles("Products", "*.jpg"))
{
    CarouselImage img = new CarouselImage();
    img.ItemImage = Image.FromFile(imagePath);
    productCarousel.ImageListCollection.Add(img);
}

this.Controls.Add(productCarousel);
csharp
// Create image-based carousel for product showcase
Carousel productCarousel = new Carousel();
productCarousel.ImageSlides = true;
productCarousel.CarouselPath = CarouselPath.Default;
productCarousel.Perspective = 4.5f;
productCarousel.TransitionSpeed = 2.0f;
productCarousel.ShowImagePreview = true;
productCarousel.ShowImageShadow = true;

// Add product images
foreach (string imagePath in Directory.GetFiles("Products", "*.jpg"))
{
    CarouselImage img = new CarouselImage();
    img.ItemImage = Image.FromFile(imagePath);
    productCarousel.ImageListCollection.Add(img);
}

this.Controls.Add(productCarousel);

Pattern 2: Auto-Rotating Dashboard Panels

示例2:自动旋转的仪表盘面板

csharp
// Create auto-rotating carousel with custom controls
Carousel dashboardCarousel = new Carousel();
dashboardCarousel.CarouselPath = CarouselPath.Orbital;
dashboardCarousel.RotateAlways = true;
dashboardCarousel.TransitionSpeed = 1.5f;
dashboardCarousel.Perspective = 3.0f;

// Add dashboard panels
Panel salesPanel = CreateDashboardPanel("Sales", salesData);
Panel inventoryPanel = CreateDashboardPanel("Inventory", inventoryData);
Panel reportsPanel = CreateDashboardPanel("Reports", reportData);

dashboardCarousel.Controls.Add(salesPanel);
dashboardCarousel.Items.Add(salesPanel);
dashboardCarousel.Controls.Add(inventoryPanel);
dashboardCarousel.Items.Add(inventoryPanel);
dashboardCarousel.Controls.Add(reportsPanel);
dashboardCarousel.Items.Add(reportsPanel);

this.Controls.Add(dashboardCarousel);
csharp
// Create auto-rotating carousel with custom controls
Carousel dashboardCarousel = new Carousel();
dashboardCarousel.CarouselPath = CarouselPath.Orbital;
dashboardCarousel.RotateAlways = true;
dashboardCarousel.TransitionSpeed = 1.5f;
dashboardCarousel.Perspective = 3.0f;

// Add dashboard panels
Panel salesPanel = CreateDashboardPanel("Sales", salesData);
Panel inventoryPanel = CreateDashboardPanel("Inventory", inventoryData);
Panel reportsPanel = CreateDashboardPanel("Reports", reportData);

dashboardCarousel.Controls.Add(salesPanel);
dashboardCarousel.Items.Add(salesPanel);
dashboardCarousel.Controls.Add(inventoryPanel);
dashboardCarousel.Items.Add(inventoryPanel);
dashboardCarousel.Controls.Add(reportsPanel);
dashboardCarousel.Items.Add(reportsPanel);

this.Controls.Add(dashboardCarousel);

Pattern 3: Linear Navigation Strip

示例3:线性导航栏

csharp
// Create linear carousel for horizontal navigation
Carousel navigationCarousel = new Carousel();
navigationCarousel.CarouselPath = CarouselPath.Linear;
navigationCarousel.TransitionSpeed = 3.0f;
navigationCarousel.Size = new Size(800, 150);
navigationCarousel.Dock = DockStyle.Top;

// Add navigation buttons
string[] sections = { "Home", "Products", "Services", "About", "Contact" };
foreach (string section in sections)
{
    ButtonAdv navButton = new ButtonAdv();
    navButton.Text = section;
    navButton.Size = new Size(120, 100);
    navButton.ButtonStyle = ButtonAppearance.Metro;
    
    navigationCarousel.Controls.Add(navButton);
    navigationCarousel.Items.Add(navButton);
}

this.Controls.Add(navigationCarousel);
csharp
// Create linear carousel for horizontal navigation
Carousel navigationCarousel = new Carousel();
navigationCarousel.CarouselPath = CarouselPath.Linear;
navigationCarousel.TransitionSpeed = 3.0f;
navigationCarousel.Size = new Size(800, 150);
navigationCarousel.Dock = DockStyle.Top;

// Add navigation buttons
string[] sections = { "Home", "Products", "Services", "About", "Contact" };
foreach (string section in sections)
{
    ButtonAdv navButton = new ButtonAdv();
    navButton.Text = section;
    navButton.Size = new Size(120, 100);
    navButton.ButtonStyle = ButtonAppearance.Metro;
    
    navigationCarousel.Controls.Add(navButton);
    navigationCarousel.Items.Add(navButton);
}

this.Controls.Add(navigationCarousel);

Pattern 4: Touch-Enabled Photo Viewer

示例4:支持触摸的图片查看器

csharp
// Create touch-friendly image carousel
Carousel photoViewer = new Carousel();
photoViewer.ImageSlides = true;
photoViewer.CarouselPath = CarouselPath.Oval;
photoViewer.Perspective = 5.0f;
photoViewer.TransitionSpeed = 2.5f;
photoViewer.ShowImagePreview = true;
photoViewer.ImageHighlightColor = Color.Gold;
photoViewer.Dock = DockStyle.Fill;

// Load photos from folder
photoViewer.FilePath = Application.StartupPath + "\\Photos";

this.Controls.Add(photoViewer);
// Touch gestures (pan, flick, pinch, stretch) work automatically
csharp
// Create touch-friendly image carousel
Carousel photoViewer = new Carousel();
photoViewer.ImageSlides = true;
photoViewer.CarouselPath = CarouselPath.Oval;
photoViewer.Perspective = 5.0f;
photoViewer.TransitionSpeed = 2.5f;
photoViewer.ShowImagePreview = true;
photoViewer.ImageHighlightColor = Color.Gold;
photoViewer.Dock = DockStyle.Fill;

// Load photos from folder
photoViewer.FilePath = Application.StartupPath + "\\Photos";

this.Controls.Add(photoViewer);
// Touch gestures (pan, flick, pinch, stretch) work automatically

Pattern 5: Themed Carousel with Custom Colors

示例5:带自定义颜色的主题化轮播

csharp
// Create visually customized carousel
Carousel themedCarousel = new Carousel();
themedCarousel.ImageSlides = true;
themedCarousel.CarouselPath = CarouselPath.Default;
themedCarousel.BackColor = Color.FromArgb(30, 30, 30);
themedCarousel.Perspective = 4.0f;
themedCarousel.TransitionSpeed = 2.0f;

// Apply custom visual effects
themedCarousel.ShowImageShadow = true;
themedCarousel.ShowImagePreview = true;
themedCarousel.ImageHighlightColor = Color.FromArgb(255, 215, 0); // Gold
themedCarousel.ImageShadeColor = Color.FromArgb(100, 100, 100);   // Gray

// Add images
foreach (var image in imageCollection)
{
    CarouselImage carouselImg = new CarouselImage();
    carouselImg.ItemImage = image;
    themedCarousel.ImageListCollection.Add(carouselImg);
}

this.Controls.Add(themedCarousel);
csharp
// Create visually customized carousel
Carousel themedCarousel = new Carousel();
themedCarousel.ImageSlides = true;
themedCarousel.CarouselPath = CarouselPath.Default;
themedCarousel.BackColor = Color.FromArgb(30, 30, 30);
themedCarousel.Perspective = 4.0f;
themedCarousel.TransitionSpeed = 2.0f;

// Apply custom visual effects
themedCarousel.ShowImageShadow = true;
themedCarousel.ShowImagePreview = true;
themedCarousel.ImageHighlightColor = Color.FromArgb(255, 215, 0); // Gold
themedCarousel.ImageShadeColor = Color.FromArgb(100, 100, 100);   // Gray

// Add images
foreach (var image in imageCollection)
{
    CarouselImage carouselImg = new CarouselImage();
    carouselImg.ItemImage = image;
    themedCarousel.ImageListCollection.Add(carouselImg);
}

this.Controls.Add(themedCarousel);

Key Properties Reference

核心属性参考

PropertyTypeDefaultDescription
CarouselPath
CarouselPathDefaultPath layout: Default, Orbital, Oval, Linear
ImageSlides
boolfalseEnable image-specific mode
Items
CarouselItemCollection-Collection of items to display
ImageListCollection
CarouselImageCollection-Collection of CarouselImage objects
FilePath
string""Folder path to load images from
Perspective
float0Zoom level of elliptical view
TransitionSpeed
float0Rotation speed multiplier
RotateAlways
boolfalseEnable continuous auto-rotation
ShowImageShadow
boolfalseDisplay shadows for images
ShowImagePreview
boolfalseShow preview of selected image at center
ImageHighlightColor
Color-Color for highlighting selected image
ImageShadeColor
Color-Color for shading background images
属性类型默认值描述
CarouselPath
CarouselPathDefault路径布局可选值:Default、Orbital、Oval、Linear
ImageSlides
boolfalse开启图片专属模式
Items
CarouselItemCollection-待展示物品的集合
ImageListCollection
CarouselImageCollection-CarouselImage对象的集合
FilePath
string""加载图片的文件夹路径
Perspective
float0椭圆视图的缩放级别
TransitionSpeed
float0旋转速度乘数
RotateAlways
boolfalse开启持续自动旋转
ShowImageShadow
boolfalse为图片展示阴影效果
ShowImagePreview
boolfalse在中心展示选中图片的预览
ImageHighlightColor
Color-选中图片的高亮颜色
ImageShadeColor
Color-背景图片的阴影颜色

Carousel Path Options

轮播路径选项

PathDescriptionUse Case
DefaultNormal elliptical arrangementGeneral carousels, balanced layouts
OrbitalOrbital curve arrangementSpace-themed displays, scientific UIs
OvalOval structure arrangementWide displays, horizontal emphasis
LinearHorizontal linear arrangementNavigation strips, horizontal galleries
路径描述使用场景
Default标准椭圆排列通用轮播、均衡布局
Orbital轨道曲线排列太空主题展示、科学类UI
Oval椭圆形结构排列宽屏展示、横向突出场景
Linear水平线性排列导航栏、横向画廊

Best Practices

最佳实践

  1. Choose Appropriate Path: Select carousel path based on layout needs (Default for general use, Linear for horizontal navigation)
  2. Add to Both Collections: Custom controls must be added to both
    Controls
    and
    Items
    collections
  3. Enable ImageSlides for Images: Set
    ImageSlides = true
    when working exclusively with images
  4. Optimize Image Count: Keep image count reasonable (6-12 items) for smooth performance
  5. Set Appropriate Speed: Use TransitionSpeed 1.5-3.0 for comfortable viewing; higher values for quick browsing
  6. Use Perspective Wisely: Perspective values 3.0-5.0 work well for most scenarios
  7. Image Sizing: Ensure images are reasonably sized (compress large images) for performance
  8. Touch-First Design: Design for touch if targeting touch devices; gestures work automatically
  9. Test Auto-Rotation: If using RotateAlways, ensure TransitionSpeed allows comfortable viewing
  10. Visual Feedback: Use ImageHighlightColor to clearly indicate selected item
  1. 选择合适的路径:根据布局需求选择轮播路径(通用场景选Default,横向导航选Linear)
  2. 同时添加到两个集合:自定义控件必须同时添加到
    Controls
    Items
    集合中
  3. 图片场景开启ImageSlides:当专门用于图片展示时设置
    ImageSlides = true
  4. 优化图片数量:保持合理的图片数量(6-12个)以保证流畅的性能
  5. 设置合适的速度:TransitionSpeed设置为1.5-3.0适合舒适浏览,快速浏览可使用更高值
  6. 合理使用透视效果:大多数场景下Perspective值3.0-5.0效果最佳
  7. 图片尺寸优化:确保图片尺寸合理(压缩大图片)以提升性能
  8. 触摸优先设计:如果目标是触摸设备,优先设计触摸友好的交互,手势可自动生效
  9. 测试自动旋转效果:如果使用RotateAlways,确保TransitionSpeed设置适配舒适的浏览速度
  10. 视觉反馈:使用ImageHighlightColor清晰标识选中的物品

Framework Support

框架支持

  • .NET Framework 4.5 and above
  • .NET 6.0, .NET 7.0, .NET 8.0 (Windows)
  • .NET Core 3.1 (Windows)
  • .NET Framework 4.5 及以上版本
  • .NET 6.0、.NET 7.0、.NET 8.0(Windows平台)
  • .NET Core 3.1(Windows平台)

Additional Resources

额外资源

Related Controls

相关控件

  • CarouselImage: Class for defining carousel image items
  • ButtonAdv: Enhanced button often used as carousel items
  • PictureBox: Standard image control
  • Panel: Container control for grouping custom content
  • CarouselImage:用于定义轮播图片项的类
  • ButtonAdv:增强型按钮,常作为轮播项使用
  • PictureBox:标准图片控件
  • Panel:用于分组自定义内容的容器控件

Troubleshooting

故障排查

Issue: Items not appearing in carousel
  • Ensure items are added to both
    Controls
    and
    Items
    collections
  • Verify carousel size is sufficient to display items
  • Check that items have appropriate size properties set
Issue: Images not displaying
  • Confirm
    ImageSlides = true
    is set
  • Verify image paths are correct
  • Check that images are added to
    ImageListCollection
Issue: Carousel not rotating
  • If using RotateAlways, ensure it's set to true
  • Check TransitionSpeed is set to a positive value
  • Verify control is visible and enabled
Issue: Touch gestures not working
  • Ensure application targets touch-enabled framework version
  • Test on actual touch device (not mouse simulation)
  • Check that carousel is in focus
Issue: Performance issues with many items
  • Reduce number of items (keep to 6-12 items)
  • Compress large images before adding
  • Lower TransitionSpeed if rotation is choppy
  • Consider disabling ShowImageShadow if performance is critical
问题:轮播中没有展示物品
  • 确保物品已经同时添加到
    Controls
    Items
    集合中
  • 确认轮播尺寸足够展示物品
  • 检查物品已经设置了合适的尺寸属性
问题:图片没有展示
  • 确认已经设置了
    ImageSlides = true
  • 验证图片路径正确
  • 检查图片已经添加到
    ImageListCollection
问题:轮播不旋转
  • 如果使用RotateAlways,确认已经设置为true
  • 检查TransitionSpeed设置为正值
  • 确认控件可见且已启用
问题:触摸手势不生效
  • 确认应用目标框架版本支持触摸功能
  • 在真实触摸设备上测试(不要使用鼠标模拟)
  • 检查轮播控件已经获得焦点
问题:物品过多时出现性能问题
  • 减少物品数量(保持6-12个)
  • 添加图片前先压缩大尺寸图片
  • 如果旋转卡顿可降低TransitionSpeed
  • 如果性能要求极高可考虑关闭ShowImageShadow