Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Image TapGestureRecognizer in ListView binding CommandParameter bug.....

$
0
0

I have a project is two columns in Listview show product, Look like this.
image

When I tap Dress_001 TapPhotoEvent will get the binding parameter ID=1, Dress_002 get ID=2, Dress_002 get ID=3 .....
Andorid binding Command & CommandParameter is OK, no problem!!
But run in iOS has a strange problem, tap Dress_007 get the ID=1, Dress_009 get the ID=7, Dress_011 get the ID=3.....
the problem video

I use TapGestureRecognizer binding Command for Image touch....
like this....

<Image Aspect="AspectFill" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <Image.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding ProductA.TapPhotoEvent}" CommandParameter="{Binding ProductA.ID}"/>
        </Image.GestureRecognizers>
</Image>

my model

public class Product
    {
        public Product ()
        {
            this.TapPhotoEvent = new Command<int> (productId => {
                System.Diagnostics.Debug.WriteLine("Touch Product Photo ID:{0}", this.ID);
            });
        }
        public int ID { get; set; }
        public string Name { get; set;}
        public double Price { get; set;}
        public string PhotoURL { get; set;}
        public ICommand TapPhotoEvent { get; set; }
    }

Code in GitHub


Viewing all articles
Browse latest Browse all 58056

Trending Articles