【发布时间】:2016-09-09 10:23:16
【问题描述】:
有没有办法在 AdaptiveGridView 工具包中获取被点击项目的索引。 这是我的代码: 页面资源:
<Page.Resources>
<DataTemplate x:Key="Photos">
<Grid>
<Image Source="{Binding ImageURL}"
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center">
</Image>
<TextBlock Text="{Binding ImageText}"
FontSize="20">
</TextBlock>
</Grid>
</DataTemplate>
</Page.Resources>
XAML:
<UWPToolkit:AdaptiveGridView x:Name="AdaptiveGV" ItemHeight="200" ItemClick="AdaptiveGV_ItemClick" DesiredWidth="200" ItemTemplate="{StaticResource Photos}"/>
后面的代码:
List<Images> ImageCollection = new List<Images>();
ImageCollection.Add(new Images()
{
ImageURL = Response[i].ProjectImageURL,
ImageText = Response[i].ProjectName
});
}
AdaptiveGV.ItemsSource = ImageCollection;
我想要获取我点击的项目的索引。有没有办法做到这一点?
【问题讨论】:
-
有一个
ItemClickCommand属性我假设你可以启动一个类似于collection.IndexOf(clickedItem)的 indexOf 方法,但我还没有使用过那个 AdaptiveGridView,只是想我会发表评论,因为没有人回答但作为一条可能的路线。