Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position of ItemClick event on a ListView Windows Phone 8.1

I have a ListView which shows the products in a shopping cart. The datatemplate defines an increment and a decrement amount button for each product.

If the user wants to tap one of these buttons, there's a chance that they tap next to the button, so the ItemClick event will be triggered. I want to disable ItemClick in the area of the button. I had an idea to get the position where the ItemClick event occurred, and determine if it's in the disabled area which I defined.

Is it possible? Any other idea?

like image 949
WPMed Avatar asked Jul 17 '15 11:07

WPMed


1 Answers

There's a simple way to do this. Use an element as the "disabled area" around these increment/decrement buttons. In the ItemClick handler, say if (e.OriginalSource == **the element which is the disabled area**) return;.

This works, because the ItemClickedEventArgs is a RoutedEventArgs which always contains the element where it originated from. See https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.itemclickeventargs

like image 96
Tamás Deme Avatar answered Nov 11 '22 07:11

Tamás Deme