Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] CollectionView: support highlight on touch-down #14103

@softlion

Description

@softlion

Summary

On a collectionview's cell, both Android and iOS views have those independent properties:

  • selected
  • highlighted

The second one is used to temporarily highlight a cell that is touch down, for example triggering the ripple effect on android.
Take note that a native view can be both selected and highlighted at the same time, leading to a different view state.

There is no such highlighted property in xamarin forms as there is no representation of the "cell" in a collectionview.
And customizing the highlightning of a CollectionView's cell on touch down is nearly impossible on Forms.

  • On Android, a workaround using a grid at the root of the DataTemplate with a simple effect can bypass this limitation, as the highlighted property is propagated to all subviews of the cell. This grid is a subview and settings a StateListDrawable as its background works as expected.

  • On iOS, there is no simple way to get the UICollectionViewCell from a control inside the DataTemplate, in order to subscribe to its highlighted property, and temporarily change its BackgroundView. And there is no way to override the renderer of the cell, as it would be a DataTemplate.

API Changes

Add highlighted state to VSM
Add IsCellHighlighted property to collectionview, or provide a way to access the underlying cell object from the datatemplate.

Intended Use Case

see above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions