0

我正在为 Windows Store 开发一个应用程序,并且我对data.js中的第一个代码进行了一些更改:

var sampleItems = [
        { group: sampleGroups[0], itemClass: "item2", title: "Pupusas:", subtitle: "Item Subtitle: 1", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/horizontal/comidas.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Atol Shuco:", subtitle: "Item Subtitle: 2", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/bebidas/atol_shuco.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Pan con Pollo:", subtitle: "Item Subtitle: 3", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/comidas/pan_pollo.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Nuegados de Huevo:", subtitle: "Item Subtitle: 4", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/postres/nuegados.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Frijoles Borrachos:", subtitle: "Item Subtitle: 5", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/comidas/frijoles_borrachos.jpg" }];

如您所见,我添加了一个名为itemClass的属性,它确定了我将要使用的 CSS 类,结果如下: http ://social.msdn.microsoft.com/Forums/getfile/214473

我知道它很好用,但我的问题是你看到的所有图片都是项目,我需要大的必须是,我有 groupedItem.js 的组和项目的代码,虽然我不知道如何合并它们,这是代码,两者都必须在 else中的_initializeLayout: function (listView, viewState)中:这是针对项目的:

            listView.itemDataSource = Data.items.dataSource;
            listView.groupDataSource = Data.groups.dataSource;

这是针对团体的:

        listView.itemDataSource = Data.groups.dataSource;
        listView.groupDataSource = null;

我想知道,如何识别“item2”?并选择项目内的组。

4

1 回答 1

1

使用args.detail.itemIndex 项目索引。这是获取索引的正确方法;您从getAt调用中获得的项目是您的数据项,除非您在其上放置索引,否则它不会具有索引属性。

于 2013-01-25T22:35:46.333 回答