문제

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?

도움이 되었습니까?

해결책 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);
    }
}

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top