SwipeCardView API

January 20, 2020 ยท View on GitHub

SwipeCardView inherits from Xamarin.Forms.ContentView.

Properties

Below are the properties for the SwipeCardView:

PropertyTypeDefaultDescription
AnimationLengthuint250The duration in milliseconds of the animation that occurs at the end of dragging movement
BackCardScalefloat0.8fScaling of back card while the front is being dragged
CardRotationfloat20Rotation adjuster in degrees for dragging to left or right. From 0 (no rotation) to 360 (full circle)
DraggingCommandSystem.Windows.Input.ICommandnullGets or sets the command to run when a dragging gesture is recognized
DraggingCommandParameterSystem.ObjectnullGets or sets the parameter to pass to commands that take one
ItemsSourceSystem.Collections.IListnullGets or sets the source of items to template and display
ItemTemplateXamarin.Forms.DataTemplatenullGets or sets the DataTemplate to apply to the ItemsSource
SupportedDraggingDirectionsSwipeCardDirectionLeft, Right, Up, DownGets or sets supported dragging direction of the top card. User may want to support dragging in all 4 directions but to support swipe movement only in a subset. For example, Tinder support dragging in all 4 directions, but has no swipe down.
SupportedSwipeDirectionsSwipeCardDirectionLeft, Right, Up, DownGets or sets direction in which top card could be swiped. User may want to support dragging in all 4 directions but to support swipe movement only in a subset. For example, Tinder support dragging in all 4 directions, but has no swipe down.
SwipeCommandSystem.Windows.Input.ICommandnullGets or sets the command to run when a swipe gesture is recognized
SwipeCommandParameterSystem.ObjectnullGets or sets the parameter to pass to commands that take one
Thresholduint100Gets or sets the minimum card dragging distance that will cause the swipe gesture to be recognized
TopItemSystem.ObjectnullGets the top item

Events

EventArguments typeDescription
SwipedSwipedCardEventArgsIt is raised on the end of the movement (just like SwipeGestureRecognizer)
DraggingDraggingCardEventArgsIt is raised during the dragging movement

EventArgs

SwipedCardEventArgs

PropertyTypeDescription
ItemSystem.ObjectGets the item parameter
ParameterSystem.ObjectGets the command parameter
DirectionSwipeCardDirectionGets the direction of the swipe

DraggingCardEventArgs

PropertyTypeDescription
ItemSystem.ObjectGets the item parameter
ParameterSystem.ObjectGets the command parameter
DirectionSwipeCardDirectionGets the direction of the swipe
PositionDraggingCardPositionGets the dragging position
DistanceDraggedXdoubleGets the distance dragged on X axis
DistanceDraggedYdoubleGets the distance dragged on Y axis

Methods

InvokeSwipe(SwipeCardDirection, UInt32, UInt32, TimeSpan)

Simulates PanGesture movement to the provided direction

Declaration

public Task InvokeSwipe(SwipeCardDirection swipeCardDirection, uint numberOfTouches, uint touchDifferenceX, TimeSpan touchDelay, TimeSpan endTouch)

Parameters

TypeNameDescription
SwipeCardDirectionswipeCardDirectionDirection of the movement. Currently supported Left and Right.
System.UInt32numberOfTouchesNumber of touch events. It should be a positive number (i.e. 20)
System.UInt32touchDifferenceXDistance passed between two touches. It should be a positive number (i.e. 10)
System.TimeSpantouchDelayDelay between two touches. It should be a positive number (i.e. 1 millisecond)
System.TimeSpanendDelayEnd delay. It should be a positive number (i.e. 200 milliseconds)

Enums

SwipeCardDirection

Enumerates swipe directions.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

NameValueDescription
None0Indicates an unknown direction
Right1Indicates a rightward swipe
Left2Indicates a leftward swipe
Up4Indicates an upward swipe
Down8Indicates a downward swipe

DraggingCardPosition

Enumerates dragging directions.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

NameValueDescription
Start0Indicates a starting position
UnderThreshold1Indicates a position under threshold
OverThreshold2Indicates a position over threshold
FinishedUnderThreshold4Indicates an ending position under threshold
FinishedOverThreshold8Indicates an ending position over threshold