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

Scrolled ListView + button click = wrong BindingContext

$
0
0

Using Xamarin.Forms 1.3.3.6323

I have a ListView with a custom cell. The custom cell contains a label and button (actually an image with tap gesture).

The label's text is bound to one of my model's properties which displays correctly when scrolled.

The image's tap event handler gets the current cell's BindingContext/model and get's the value of a description property and displays it using DisplayAlert. This work fine for items that never leave the screen or even go just off-screen. The problem is if there are 3-4+ items beyond the screen. Let's say I scroll to the bottom and tap the image button of the last item...the BindingContext that it gets is from one of the items that was scrolled out of view and so the wrong description is displayed.

I'm guessing it's somehow due to cell reuse.

Only tested on iPhone so far btw.

Any ideas on how to make this work? Should I be doing something differently?

I'd be happy with a hack to get it to work at this point because I need to get this app published this week to meet a deadline and marketing just alerted me to this problem yesterday. I've been trying to come up with a workaround/hack myself, but no luck yet.

Let me know if you need anything else from me to understand the problem better.

Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles