Skip to main content

Carousel

Overview

Grial's Carousel is used to display a list of elements in a similar fashion than .NET MAUI's CarouselView. It's very flexible, providing properties to control its looks, its behavior, and its animations. As an example, you can define a scaling factor for the previous and next element; and, when combined with the peek area looks like this:

Carousel animation
  • Animations: comes with two different pre-baked animations that differ on how the items scaling factors update while moving

  • Commands: MoveEndedCommand and PositionChangedCommand to notify ViewModels when the control did change; MoveNextCommand and MovePrevCommand to animate the carousel from a bound command

  • Mode-View-ViewModel ready: the content is defined through ItemsSource and ItemTemplate properties, and it provides a variety of commands and properties to pass the Carousel state to your ViewModels and control it from C# code

  • Optimized for performance: it’s 100% virtualized by default, it’s possible to opt out though

  • Flexible API: loop, position, item separation, selected item, enable/disable dragging, enable/disable position changes, events and differentiated item peek percentage and scale on each side

  • Progressive Animations integration: exposes ScrollProgress property which enables direct integration with Grial’s Progressive Animations‍

  • Indicator view support: can be linked to an IndicatorView in the same as MAUI’s CarouselView

Carousel animation

Properties

NameTypeDescription
AnimationAnimationTypeGets or sets the animation type from the the available predefined values.
CachingStrategyCachingStrategyGets or sets the strategy used for virtualization.
CanMoveNextboolGets or sets whether the control can move to the next position or not.
CanMovePrevboolGets or sets whether the control can move to the previous position or not.
IndicatorViewIndicatorViewGets or sets an IndicatorView instance to associate to the Carousel.
IsDraggingEnabledboolGets or sets whether drag/swipe user interaction is enabled or not.
ItemSeparationdoubleGets or sets separation between items.
ItemsSourceIEnumerableGets or sets the data collection used to populate the Carousel.
ItemTemplateDataTemplateGets or sets the DataTemplate used to display the items set in the ItemsSource.
LoopboolGets or sets whether the Carousel should loop or not.
MoveEndedCommandParameterobjectGets or sets the command parameter passed to MoveEndedCommand. If nothing is specified an instance of CarouselMovedEndedEventArgs is used.
NextPeekPercentagedoubleGets or sets the percentage of the Carousel's area used to peek the next item.
NextPeekScaledoubleGets or sets the scaling factor used to display the next item.
PeekPercentagedoubleGets or sets the percentage of the Carousel's area used to peek the previous and next items.
PeekScaledoubleGets or sets the scaling factor used to display the previous and next items.
PositionintGets or sets the Position of the item currently displayed at the center.
PositionChangedCommandParameterobjectGets or sets the command parameter passed to PositionChangedCommand. If nothing is specified an instance of CarouselPositionChangedEventArgs is used.
PrevPeekPercentagedoubleGets or sets the percentage of the Carousel's area used to peek the previous item.
PrevPeekScaledoubleGets or sets the scaling factor used to display the previous item.
ScrollProgressdoubleGets the a value indicating the change in the scroll while the Carousel is moving. The value is always between -1 and 1.
SelectedItemobjectGets or sets whether the selected item, i.e. the item currently displayed at the center.

Events

NameTypeDescription
MovedEventHandler<RelativeMoveEventArgs>Event invoked while the Carousel is moving.
MoveEndedEventHandler<CarouselMovedEndedEventArgs>Event invoked when the Carousel ends moving.
PositionChangedEventHandler<CarouselPositionChangedEventArgs>Event invoked when the Carousel position changes.

Commands

NameTypeDescription
MoveEndedCommandICommandGets or sets a command invoked when the Carousel stops moving.
MoveNextCommandICommandGets a command invoked when the Carousel moves to the next position.
MovePrevCommandICommandGets a command invoked when the Carousel moves to the previous position.
PositionChangedCommandICommandGets or sets a command invoked when the Carousel's Position changes.

Methods

NameTypeDescription
MoveNextAnimated(int duration = 200)Task<bool>Makes the Carousel move to the next element with the indicated animation duration.
MovePrevAnimated(int duration = 200)Task<bool>Makes the Carousel move to the previous element with the indicated animation duration.