Class SkiaCarousel
A specialized scroll control designed for creating swipeable carousels with automatic snapping to items. Supports data binding through ItemsSource and ItemTemplate, peek effects with SidesOffset, and smooth transitions. Ideal for image galleries, tab interfaces, and any swipeable content display.
public class SkiaCarousel : SnappingLayout, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IVisualElementController, IElementController, IView, ITransform, IElement, IVisualTreeElement, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISkiaGestureListener, IHasAfterEffects, ISkiaDisposable, ISkiaGridLayout, ISkiaLayout, ISkiaControl, IDrawnBase, ICanBeUpdatedWithContext, ICanBeUpdated, ILayoutInsideViewport, IInsideViewport, IVisibilityAware, IDisposable
- Inheritance
-
SkiaCarousel
- Implements
- Inherited Members
- Extension Methods
Constructors
SkiaCarousel()
public SkiaCarousel()
Fields
ChildrenInitialized
protected bool ChildrenInitialized
Field Value
ChildrenTotalProperty
public static readonly BindableProperty ChildrenTotalProperty
Field Value
DynamicSizeProperty
public static readonly BindableProperty DynamicSizeProperty
Field Value
IsLoopedProperty
public static readonly BindableProperty IsLoopedProperty
Field Value
IsRightToLeftProperty
public static readonly BindableProperty IsRightToLeftProperty
Field Value
IsVerticalProperty
public static readonly BindableProperty IsVerticalProperty
Field Value
LinearSpeedMsProperty
public static readonly BindableProperty LinearSpeedMsProperty
Field Value
PreloadNeighboorsProperty
public static readonly BindableProperty PreloadNeighboorsProperty
Field Value
SelectedIndexProperty
public static readonly BindableProperty SelectedIndexProperty
Field Value
SidesOffsetProperty
public static readonly BindableProperty SidesOffsetProperty
Field Value
SwipeSpeedProperty
public static readonly BindableProperty SwipeSpeedProperty
Field Value
_panningOffset
protected Vector2 _panningOffset
Field Value
_panningStartOffset
protected Vector2 _panningStartOffset
Field Value
Properties
CanRender
protected virtual bool CanRender { get; }
Property Value
CellSize
public ScaledSize CellSize { get; set; }
Property Value
ChildrenCount
public int ChildrenCount { get; set; }
Property Value
ChildrenReady
protected virtual bool ChildrenReady { get; }
Property Value
ChildrenTotal
Can be used for indicators
public int ChildrenTotal { get; set; }
Property Value
DynamicSize
When specific dimension is adapting to children size, will use max child dimension if False, otherwise will change size when children with different dimension size are selected. Default is false. If true, requires MeasureAllItems to be set to all items.
public bool DynamicSize { get; set; }
Property Value
IsAtEnd
public virtual bool IsAtEnd { get; }
Property Value
IsAtStart
public virtual bool IsAtStart { get; }
Property Value
IsLooped
UNIMPLEMENTED YET
public bool IsLooped { get; set; }
Property Value
IsRightToLeft
TODO
public bool IsRightToLeft { get; set; }
Property Value
IsUserFocused
public bool IsUserFocused { get; protected set; }
Property Value
IsUserPanning
public bool IsUserPanning { get; protected set; }
Property Value
IsVertical
Orientation of the carousel
public bool IsVertical { get; set; }
Property Value
ItemsVisibility
protected ConcurrentDictionary<int, bool> ItemsVisibility { get; }
Property Value
LastIndex
public int LastIndex { get; set; }
Property Value
LastScrollProgress
protected double LastScrollProgress { get; set; }
Property Value
LinearSpeedMs
How long would a whole auto-sliding take, if Bounces is False.
If set (>0) will be used for automatic scrolls instead of using manual velocity.
For bouncing carousel
public double LinearSpeedMs { get; set; }
Property Value
MaxIndex
public int MaxIndex { get; set; }
Property Value
PreloadNeighboors
Whether should preload neighboors sides cells even when they are hidden, to preload images etc.. Default is true. Beware set this to False if you have complex layouts otherwise rendering might be slow.
public bool PreloadNeighboors { get; set; }
Property Value
SafeIndex
Will be updated on MainThread to safely work with bindings, this a read-only property returning SelectingIndex in a thread-safe way;
public int SafeIndex { get; }
Property Value
ScrollAmount
Scroll amount from 0 to 1 of the current (SelectedIndex) slide. Another similar but different property would be ScrollProgress. This is not linear as SelectedIndex changes earlier than 0 or 1 are attained.
public double ScrollAmount { get; set; }
Property Value
ScrollProgress
Scroll progress from 0 to (numberOfSlides-1). This is not dependent of the SelectedIndex, just reflects visible progress. Useful to create custom controls attached to carousel. Calculated as (for horizontal): CurrentPosition.X / SnapPoints.Last().X
public double ScrollProgress { get; set; }
Property Value
SelectedIndex
Zero-based index of the currently selected slide
public int SelectedIndex { get; set; }
Property Value
SidesOffset
Basically size margins of every slide, offset from the side of the carousel. Another similar but different property to use would be Spacing between slides.
public double SidesOffset { get; set; }
Property Value
SnapPointsVirtual
protected List<SkiaCarousel.SnapPoint> SnapPointsVirtual { get; set; }
Property Value
SwipeSpeed
Used inside ScrollToOffset to control the speed
public double SwipeSpeed { get; set; }
Property Value
TransitionProgress
public double TransitionProgress { get; }
Property Value
VelocityAccumulator
protected VelocityAccumulator VelocityAccumulator { get; }
Property Value
WillClipBounds
Used to check whether to apply IsClippedToBounds property
public override bool WillClipBounds { get; }
Property Value
Methods
AdaptChildren()
Set children layout options according to our settings. Not used for template case.
protected virtual void AdaptChildren()
AdaptTemplate(SkiaControl)
protected void AdaptTemplate(SkiaControl skiaControl)
Parameters
skiaControlSkiaControl
AnimateVisibleChild(SkiaControl, Vector2)
protected virtual void AnimateVisibleChild(SkiaControl view, Vector2 position)
Parameters
viewSkiaControlpositionVector2
ApplyDynamicSize(int)
protected virtual void ApplyDynamicSize(int index)
Parameters
indexint
ApplyIndex(bool)
public virtual void ApplyIndex(bool instant = false)
Parameters
instantbool
ApplyOptions(bool)
public override void ApplyOptions(bool initialize)
Parameters
initializebool
ApplyPosition(Vector2)
Will translate child and raise appearing/disappearing events
public override void ApplyPosition(Vector2 currentPosition)
Parameters
currentPositionVector2
CalculateChildPosition(Vector2, int, int)
protected virtual (Vector2 Offset, bool OnScreen, bool NextToScreen) CalculateChildPosition(Vector2 currentPosition, int index, int childrenCount)
Parameters
Returns
CheckConstraints()
protected virtual void CheckConstraints()
CheckTransitionEnded()
public override bool CheckTransitionEnded()
Returns
CreateContentFromTemplate()
public override object CreateContentFromTemplate()
Returns
FindNearestAnchorInternal(Vector2, Vector2)
protected override Vector2 FindNearestAnchorInternal(Vector2 current, Vector2 velocity)
Parameters
Returns
FixIndex()
public virtual void FixIndex()
FixPosition()
Set true position if inside virtual for IsLooped
protected virtual void FixPosition()
GetContentOffsetBounds()
There are the bounds the scroll offset can go to.. This are NOT the bounds of the whole content.
public override SKRect GetContentOffsetBounds()
Returns
GetTemplatesPoolLimit()
protected override int GetTemplatesPoolLimit()
Returns
GetTemplatesPoolPrefill()
protected override int GetTemplatesPoolPrefill()
Returns
GetVirtualAnchor(Vector2, Vector2)
protected virtual SkiaCarousel.SnapPoint GetVirtualAnchor(Vector2 current, Vector2 velocity)
Parameters
Returns
GetVirtualSnapPoints()
protected virtual List<SkiaCarousel.SnapPoint> GetVirtualSnapPoints()
Returns
GoNext()
public void GoNext()
GoPrev()
public virtual void GoPrev()
InitializeChildren()
We expect this to be called after this alyout is invalidated
public virtual void InitializeChildren()
OnChildAdded(SkiaControl)
public override void OnChildAdded(SkiaControl child)
Parameters
childSkiaControl
OnChildrenInitialized()
protected virtual void OnChildrenInitialized()
OnDisposing()
Base performs some cleanup actions with Superview
public override void OnDisposing()
OnItemSourceChanged()
public override void OnItemSourceChanged()
OnLayoutChanged()
DrawingRect size changed
protected override void OnLayoutChanged()
OnScrollProgressChanged()
protected virtual void OnScrollProgressChanged()
OnSelectedIndexChanged(int)
protected virtual void OnSelectedIndexChanged(int index)
Parameters
indexint
OnTemplatesAvailable()
This might be called from background thread if we set InitializeTemplatesInBackgroundDelay true
public override void OnTemplatesAvailable()
OnTransitionChanged()
Invokes TransitionChanged event
public override void OnTransitionChanged()
ProcessGestures(SkiaGesturesParameters, GestureEventProcessingInfo)
public override ISkiaGestureListener ProcessGestures(SkiaGesturesParameters args, GestureEventProcessingInfo apply)
Parameters
argsSkiaGesturesParametersapplyGestureEventProcessingInfo
Returns
RenderViewsList(DrawingContext, IEnumerable<SkiaControl>)
Use to render Absolute layout. Base method is not supporting templates, override it to implement your logic. Returns number of drawn children.
protected override int RenderViewsList(DrawingContext context, IEnumerable<SkiaControl> skiaControls)
Parameters
contextDrawingContextskiaControlsIEnumerable<SkiaControl>
Returns
RenderVisibleChild(DrawingContext, SkiaControl, Vector2)
protected virtual void RenderVisibleChild(DrawingContext context, SkiaControl view, Vector2 position)
Parameters
contextDrawingContextviewSkiaControlpositionVector2
ScrollToNearestAnchor(Vector2, Vector2)
public override void ScrollToNearestAnchor(Vector2 location, Vector2 velocity)
Parameters
ScrollToOffset(Vector2, Vector2, bool)
protected override bool ScrollToOffset(Vector2 targetOffset, Vector2 velocity, bool animate)
Parameters
Returns
SelectNextAnchor(Vector2, Vector2)
Return an anchor depending on direction and strength of of the velocity
public override Vector2 SelectNextAnchor(Vector2 origin, Vector2 velocity)
Parameters
Returns
SetupViewport()
protected void SetupViewport()
UpdateReportedPosition()
public override void UpdateReportedPosition()
Events
ItemAppearing
public event EventHandler<int> ItemAppearing
Event Type
ItemDisappearing
public event EventHandler<int> ItemDisappearing
Event Type
SelectedIndexChanged
public event EventHandler<int> SelectedIndexChanged
Event Type
Stopped
public event EventHandler<Vector2> Stopped