Answered by:
trouble in handling click and touch events on listview in xaml

Question
-
I have created a listview in xaml. My requirements are-
Mouse click
left click - leftclick handler and get the selected item index
right click - rightclick handler and get the selected item indexTouch
tap - same behavior as left click
swipe - same behavior as right clickMy code :
<ListView x:Name="myList" ItemsSource="{Binding myList}" SelectionMode="Single" IsSwipeEnabled="True" Tapped="onItemSelected" RightTapped="onItemRightTapped"/>
I want only one item to be selected at a time.
On left clicking, event handler is invoked and i can use the selected index.
On right clicking, i am facing trouble to invoke the handler and find the selected index.Any help ?
- Moved by Jeff SandersMicrosoft employee, Moderator Monday, January 6, 2014 7:47 PM xaml
Monday, January 6, 2014 4:08 AM
Answers
-
Did you try this technique:
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Proposed as answer by Jamles HezModerator Thursday, January 16, 2014 8:27 AM
- Marked as answer by Jamles HezModerator Tuesday, January 21, 2014 2:22 AM
Tuesday, January 7, 2014 2:32 PMModerator
All replies
-
You did not enable the right tap.
See the documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.righttapped.aspx
PS, I would not do this. RightTapped is reserved for context menus and this will confuse your users potentially resulting in bad review scores for your app.
Jeff
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, January 6, 2014 7:56 PM
Monday, January 6, 2014 7:55 PMModerator -
Even if I enable the right tap, the right tap handler is not invoked.
As I saw in some articles, right tap handler is automatically swallowed and is not invoked if we set the selection mode not equal to none.I need selection of listview item and event handlers for both left and right clicks.
Tuesday, January 7, 2014 12:04 PM -
Did you try this technique:
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Proposed as answer by Jamles HezModerator Thursday, January 16, 2014 8:27 AM
- Marked as answer by Jamles HezModerator Tuesday, January 21, 2014 2:22 AM
Tuesday, January 7, 2014 2:32 PMModerator