0
votes

This should be very easy to implement. I'm trying to get selected item in a longlistselector when user taps on a row. There are some ways but most appropriate solution is to handle Tap event or SelectionChanged event. But there is a strange problem with those events. If user taps empty space on longlistselector, SelectionChanged event doesn't raise and Tap event returns null for SelectedItem property or returns last SelectedItem if you didn't set it to null. If users taps on any item in a row this events works correctly. By the way this is applicable for itemtemplated longlistselectors.

This makes me crazy, very easy but it is just not working correctly. Do you know whats going on under the hood or how to handle this?

1
What do you mean by row? LongListSelector contains items not rows. What do you want to achieve? Do you want to get the SelectedItem DataContext? We won't be able to help you if you don't show us some code. - Pantelis

1 Answers

0
votes

Yeah, I had those problems too. Really is better to use the SelectionChange event, handle there what you need with the selected item, and later set the selected item to null. That way the SelectionChange event will work fine everytime. Actually the problem with SelectionChange is that if you tap again in the same item, it won't be fired, because the Selection haven't changed, that's why you need to set the selected item equals to null.

Hope this helps