Skip to main content

Swipeable Layout

Overview

The SwipeableLayout exemplifies the flexibility that defines all our controls. Whether you want to showcase a few items in an engaging loop with smooth animations or implement a simple binary choice interface (like yes/no, true/false), the SwipeableLayout has got you covered.

Swipeable Layout Sample
  • Rich Interactions: The star feature is its intuitive and smooth swiping interaction. It offers two predefined options, where items move slightly up or down as they are swiped off the screen, creating a polished user experience.

  • MVVM ready: Easily integrate with the MVVM pattern using ItemsSource and ItemTemplate properties. The control provides various commands and properties to pass its state to your ViewModels, making it simple to control from C# code.

  • Commands for everything: Supports a wide range of commands to keep your ViewModels in sync. Use MoveEndedCommand and PositionChangedCommand to notify ViewModels of changes, and MoveNextCommand and MovePrevCommand to programmatically control the carousel from the ViewModel.

  • Optimized for performance: It’s 100% virtualized by default, ensuring optimal performance. You can opt out of virtualization if needed.

  • Empty View Template: Provide a unique view when there are no items or if the user has swiped away all items and looping is disabled.

  • Progressive Animations integration: Exposes ScrollProgress property enabling seamless integration with Grial’s Progressive Animations‍.

  • Indicator view support: Can be linked to an IndicatorView in the same way as Grial’s Carousel or MAUI’s CarouselView

Control API

Properties

NameTypeDescription
AnimationAnimationTypeGets or sets the kind of animation that would be use to swipe the elements. Possible values are: RotateDown, RotateUp.
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.
EmptyViewTemplateDataTemplateGets or sets the template for the empty view.
IndicatorViewIndicatorViewGets or sets an IndicatorView instance to associate to the Carousel.
IsDraggingEnabledboolGets or sets whether drag/swipe user interaction is enabled or not.
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.
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.
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.