如何确定单击了哪个孩子ListView项的元素? [英] How to determine which child element of a ListView Item was clicked?

查看:227
本文介绍了如何确定单击了哪个孩子ListView项的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发XAML和C#中的Windows Phone 8.1的应用程序。我有一个ListView从绑定列表获取其项目,并通过一个DataTemplate显示它们。现在,在这个DataTemplate中有多个子元素,当用户点击列表中的一个项目,我希望能够确定哪些子元素,他居然感动。根据所,应用程序要么扩大与更多的细节视图中的项目里面,或者导航到另一个页面。

I'm developing a windows phone 8.1 app in XAML and C#. I have a ListView getting its Items from a bound list and displaying them through a DataTemplate. Now, in this DataTemplate there are multiple child elements, and when the user taps on an item in the list, I want to be able to determine what child element he actually touched. Depending on that, the app should either expand a view with more details inside the Item, or navigate to another page.

在ListView的itemClick事件处理程序是ListView_ItemClick(对象发件人,ItemClickEventArgs E),我想e.OriginalSource会也许给我答案,但是这只是给我的点击列表项。

The ItemClick event handler of the ListView is ListView_ItemClick(object sender, ItemClickEventArgs e), and I thought e.OriginalSource would maybe give me the answer, but this just gave me the clicked ListItem.

我还没有尝试,如果带有按钮封装的孩子和他们的拦截点击事件会的工作,但我很高兴去尝试任何其他有可能是这一点。

I have yet to try if encapsulating the children with buttons and intercepting their click events would work, but I'm happy to try any alternative there might be for this.

推荐答案

我刚刚找到了解决办法喽。我在ListView设置的SelectionMode =none和IsItemClickEnabled =FALSE,然后我加螺纹的处理程序各个子元素。作品一样,我想。

I just found the solution myself. I set the ListView to SelectionMode="None" and IsItemClickEnabled="False", and then I added Tapped handlers for the individual child elements. Works just as I wanted.

这篇关于如何确定单击了哪个孩子ListView项的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆