Question

I have an UICollectionView with AllowsMultipleSelection = true, and I binded SelectionChangedCommand of MvxCollectionViewSource, but SelectionChangedCommand triggers only on selection. How can I bind deselection? Is there anything like DeselectionChangedCommand?

Was it helpful?

Solution 2

Thank you for answer, but it isn't firing with a null value on deselected. But I found solution:

public class MvxCollectionViewDSSource: MvxCollectionViewSource
{

    public MvxCollectionViewDSSource(UICollectionView collectionView)
        : base(collectionView)
    {
    }

    public MvxCollectionViewDSSource(UICollectionView collectionView,
        NSString defaultCellIdentifier)
        : base(collectionView, defaultCellIdentifier)
    {
    }

    public override void ItemDeselected(UICollectionView collectionView, NSIndexPath indexPath)
    {
        var item = GetItemAt(indexPath);

        var command = SelectionChangedCommand;
        if (command != null)
            command.Execute(item);
    }
}

OTHER TIPS

when item deselected, isn't SelectionChangedCommand firing with a null ? if it doesn't you could subscribe to the selection event of the control in the controller and on event handler call the SelectionChangedCommand with null

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top