Xamarin Form CollectionView Change Highlight Color

ashraftm@gmail.com 16 Reputation points
2021-05-10T19:40:23.95+00:00

I don't see an option to change Xamarin CollectionView Highlight Color (when pressing down and hold before release iOS). I want to change the default gray highlight color in iOS (Please don't confuse this with the selected collection view color, which we can change with VisualStateManager)

95319-fullsizerender.gif

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mr. Onion 16 Reputation points
    2022-01-14T09:58:07.037+00:00

    For those who stumbled upon this as well:

       public class ExtendedCollectionViewRenderer
       : GroupableItemsViewRenderer<GroupableItemsView, CustomGroupableItemsViewController>
    {
         protected override CustomGroupableItemsViewController CreateController(
            GroupableItemsView itemsView,
            ItemsViewLayout layout)
        {
            return new CustomGroupableItemsViewController(itemsView, layout);
        }
    }
    
    public class CustomGroupableItemsViewController : GroupableItemsViewController<GroupableItemsView>
    {
        public CustomGroupableItemsViewController(GroupableItemsView groupableItemsView, ItemsViewLayout layout)
            : base(groupableItemsView, layout)
        {
        }
        protected override UICollectionViewDelegateFlowLayout CreateDelegator()
        {
            return new CustomGroupableItemsViewDelegator(ItemsViewLayout, this);
        }
    }
    
    public class CustomGroupableItemsViewDelegator
        : GroupableItemsViewDelegator<GroupableItemsView, CustomGroupableItemsViewController>
    {
        public CustomGroupableItemsViewDelegator(
            ItemsViewLayout itemsViewLayout, 
            CustomGroupableItemsViewController itemsViewController)
            : base(itemsViewLayout, itemsViewController)
        {
        }
        public override void ItemHighlighted(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var cell = collectionView.CellForItem(indexPath);
            if (cell != null)
            {
                cell.SelectedBackgroundView = null;
            }
        }
    }
    
    3 people found this answer helpful.

  2. softlion 1 Reputation point
    2022-04-15T07:42:09.75+00:00

    @Mr. Onion do you have the same for android maybe ? Ty !


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.