SelectionChangedCommand issue on CollectionView

stesvisstesvis USMember ✭✭✭
edited February 14 in Xamarin.Forms

Well, I was excited to use this command on the CollectionView but either I am using it wrong, or it doesn't work:

<CollectionView ItemsSource="{Binding FeaturedHubs}" SelectionMode="Single" SelectionChangedCommand="{Binding HubTappedCommand}">

And then in the ViewModel I have the Prism command:

        private DelegateCommand<object> _hubTappedCommand;
        public DelegateCommand<object> HubTappedCommand =>
            _hubTappedCommand ?? (_hubTappedCommand = new DelegateCommand<object>(ExecuteHubTappedCommand));

However, that ExecuteHubTappedCommand command never fires. What am I missing? This is in android, i haven't tested iOS.

I can use the TapGestureRecognizer in the ItemTemplatee, but it would be really nice if the SelectionChangedCommand worked.

Best Answer

Answers

  • stesvisstesvis USMember ✭✭✭

    Thanks @LandLu I think the difference is the SelectionChangedCommandParameter.
    I was not defining it, expecting to just receive an object, but instead it did not execute the command at all.

    After adding the SelectionChangedCommandParameter it fires correctly.

Sign In or Register to comment.