[英]Select ListView GroupStyle Items
I have a ListView with GroupStyle in UWP like in the example here . 我在UWP与GroupStyle一个ListView像例子在这里 。 I have the following HeaderTemplate :
我有以下HeaderTemplate :
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="data:GroupInfoList">
<Grid Tapped="Header_Tapped">
<TextBlock Text="{x:Bind Key}" />
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
and I can get the selected Key by 我可以通过以下方式获取所选的密钥
private void Header_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
var selItem = (sender as Grid).DataContext as GroupInfoList;
var selKey = selItem.Key;
}
Now my problem is that despite knowing the selected Key , I cannot access the Items from it. 现在我的问题是,尽管知道所选的键 ,但我无法从中访问项目 。 In Debug, I can see the Count Property and it is equal to the number of elements, that are inside the Group, but I do not know, how to iterate through it.
在Debug中,我可以看到Count属性,它等于Group内元素的数量,但是我不知道如何遍历它。
I would very much like to iterate through all Items, that have the same Key as selKey and set a boolean property called _isVisible for all those items. 我非常想遍历所有与selKey相同的Key的项目,并为所有这些项目设置一个名为_isVisible的布尔属性。 What is a good/fast/effective way to accomplish this?
有什么好的/快速/有效的方法来完成此任务?
GroupInfoList
is derived from List<object>
. GroupInfoList
派生自List<object>
。 It contains all the Contact
with the same Key
. 它包含具有相同
Key
所有Contact
。 When you get selItem
, you can use following code to iterate through it like iterate through a List
. 当您获得
selItem
,可以使用以下代码进行迭代,就像遍历List
。
foreach (var item in selItem)
{
var contact = item as Contact;
//suppose you have add a _isVisible property in Contact
contact._isVisible = true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.