[ 本文适用于编写 Windows 运行时应用的 Windows 8.x 和 Windows Phone 8.x 开发人员。如果你要针对 Windows 10 进行开发,请参阅 最新文档 ]
定义一项,其中包含一个图标、一个较大的粗体标题、一个较小的副标题和描述性文本。 此模板可以与具有列表布局的 ListView 结合使用。有关更多模板,请参阅网格布局的项模板和列表布局的项模板。
要使用该模板
要使用该模板,需将 HTML 和 CSS 样式复制到你的项目中。HTML 包含专用于该模板的 ListView。在你复制 HTML 之后,将 ListView 控件的 itemDataSource 设置为你的应用的数据源,并更新模板的 data-win-bind 属性以便它们能使用你的数据。
若要该模板正常工作,请将 win-selectionstylefilled
类分配给你的 ListView。
HTML
<!-- Item template -->
<div id="imageTextListCollectionTemplate"
data-win-control="WinJS.Binding.Template">
<div class="imageTextListCollection">
<img class="imageTextListCollectionImage"
data-win-bind="src: icon"/>
<div class="imageTextListCollectionTextArea">
<h4 class="imageTextListCollectionTextStrong"
data-win-bind="innerText: largeText"></h4>
<h6 class="imageTextListCollectionTextLight"
data-win-bind="innerText: smallText"></h6>
<div class="imageTextListCollectionText"
data-win-bind="innerText: mediumText"></div>
</div>
</div>
</div>
<!-- ListView -->
<div id="imageTextListCollection"
class="win-selectionstylefilled"
data-win-control="WinJS.UI.ListView"
data-win-options="{ itemDataSource: list.dataSource,
itemTemplate: select('#imageTextListCollectionTemplate'),
layout: { type: WinJS.UI.ListLayout } }">
</div>
CSS
/* overall list dimensions */
#imageTextListCollection {
margin: 0px 110px;
width: 531px; /* +31 px to account for margins applied by ListView */
height: 637px;
}
/*-------------------------------------------------------------------------------------------*/
/* imageTestList-collection - used in app template collection page in portrait*/
/*-------------------------------------------------------------------------------------------*/
/* style the background color of the filled-selection style items */
.win-selectionstylefilled :not(.win-footprint).win-container {
background-color: transparent;
}
.win-selectionstylefilled .win-container.win-swipe:hover {
background-color: transparent;
}
/* individual item dimensions */
#imageTextListCollection .imageTextListCollection {
display: -ms-grid;
width: 100%;
height: 120px;
padding: 5px;
overflow: hidden;
}
/* image */
.imageTextListCollection img.imageTextListCollectionImage {
-ms-grid-column: 1;
width: 110px;
height: 110px;
margin: 5px;
}
.imageTextListCollection .imageTextListCollectionTextArea {
-ms-grid-column: 2;
margin: 9px 5px 5px 5px;
line-height: 20px;
}
/* text line 1 */
.imageTextListCollection .imageTextListCollectionTextStrong {
width: 360px;
height: 20px;
overflow: hidden;
}
/* text line 2 */
.imageTextListCollection .imageTextListCollectionTextLight {
width: 360px;
height: 20px;
overflow: hidden;
}
/* text line 3 */
.imageTextListCollection .imageTextListCollectionText {
width: 360px;
height: 60px;
overflow: hidden;
}