简体   繁体   English

给定GridView上的ItemClick事件,我如何知道被单击的组?

[英]Given the ItemClick event on a GridView, how do I know the group that was clicked?

I have a GridView that displays grouped items (similar to the default project on Win8 store apps). 我有一个GridView显示分组的项目(类似于Win8应用商店应用程序的默认项目)。

The difference is that each group may contain the same items as others. 不同之处在于每个组可能包含与其他组相同的项目。

I need to know, for the item, which group it was clicked in. 我需要知道该项目是在哪个组中单击的。

[Edit: Removed "item was clicked"] [编辑:删除了“已单击项目”]

I know how work around the issue by walking the visual tree (and not using the ItemClick event) - but I want to know if there's a standard way for doing that. 我知道如何通过遍历可视化树(而不使用ItemClick事件)来解决此问题-但我想知道是否有标准的方法可以做到这一点。

Are you using the default SampleDataSource class? 您是否使用默认的SampleDataSource类? If you are, in the ItemView_ItemClick event, you can get the ID for the group using the following code 如果是,则在ItemView_ItemClick事件中,可以使用以下代码获取组的ID。

        var groupId = ((SampleDataItem)e.ClickedItem).Group;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM