[英]WP8.1 Click event for child element in ListView ItemTemplate while ignoring ItemClick event
I have a ListView
with a DataTemplate. 我有一个带有DataTemplate的
ListView
。 Inside the DataTemplate I have a clickable image 在DataTemplate内部,我有一个可点击的图像
<Image x:Name="likeImg" Tapped="likeButtonPressed" Margin="2" VerticalAlignment="Bottom" Height="20" Source="{Binding likedImage}" Visibility="{Binding userID, Converter={StaticResource ResourceKey=HideForMyUser}}"/>
This event fires perfectly when clicked. 单击该事件会完美触发。
I added an ItemClick
event handler to the ListView
(and IsItemClickEnabled
true of course) so that when an item is clicked, I want to navigate to a new page EXCEPT when the likeImg
is clicked. 我在
ListView
添加了一个ItemClick
事件处理程序(当然,还为IsItemClickEnabled
true),以便单击某项时, likeImg
单击likeImg
,我还想导航到新页面。 When I click the likeImg
both events fire. 当我单击
likeImg
两个事件都会触发。 Is there any way to ignore the ItemClick event when the image is tapped? 点击图像时,有什么方法可以忽略ItemClick事件吗?
Disable the SelectionMode
and IsItemClickEnabled
of ListView and your child control (Image in your case) event should fire. 禁用ListView的
SelectionMode
和IsItemClickEnabled
,然后应触发子控件(在您的情况下为Image)事件。
Below are the ListView Properties you should set. 下面是您应该设置的ListView属性。
SelectionMode="None"
IsItemClickEnabled="False"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.