图像和文本列表(集合贴靠)模板 (HTML)

[ 本文适用于编写 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="imageTextListCollectionSnapTemplate" 
     data-win-control="WinJS.Binding.Template">
  <div class="imageTextListCollectionSnap">
    <img class="imageTextListCollectionSnapImage" 
         data-win-bind="src: icon"/>
    <div class="imageTextListCollectionSnapText">
      <div class="imageTextListCollectionSnapTextTitle" 
           data-win-bind="innerText: largeText"></div>
      <h6 class="imageTextListCollectionSnapTextDescription" 
          data-win-bind="innerText: smallText"></h6>
    </div>
  </div>
</div>

<!-- ListView -->
<div id="imageTextListCollectionSnap" 
    class="win-selectionstylefilled"
    data-win-control="WinJS.UI.ListView"
    data-win-options="{ itemDataSource: list.dataSource, 
        itemTemplate: select('#imageTextListCollectionSnapTemplate'), 
        layout: { type: WinJS.UI.ListLayout } }">
</div>

CSS

/* overall list dimensions */
#imageTextListCollectionSnap {
    margin-left: 110px;
    width: 323px; /* +31 px to account for margins applied by ListView */
    height: 640px;
}

/*-------------------------------------------------------------------------------------------*/
/* imageTextList-collectionSnap - used in app template collection page snap view*/
/*-------------------------------------------------------------------------------------------*/

/* 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;
}

/* margins between items */
#imageTextListCollectionSnap .win-container {
    margin-top: 0px;
    margin-bottom: 0px;
}

    /* hide the hover outline for edge-to-edge items */
    #imageTextListCollectionSnap .win-container:hover {
        outline: none;
    }

/* individual item dimensions */
.imageTextListCollectionSnap {
    display: -ms-grid;
    width: 282px;
    height: 70px;
    padding: 5px;
    overflow: hidden;
}

    /* image */
    .imageTextListCollectionSnap img.imageTextListCollectionSnapImage {
        -ms-grid-column: 1;
        margin: 5px;
        width: 60px;
        height: 60px;
    }

    .imageTextListCollectionSnap .imageTextListCollectionSnapText {
        margin: 5px;
        -ms-grid-column: 2;
    }

        /* Text line 1 */
        .imageTextListCollectionSnap .imageTextListCollectionSnapText .imageTextListCollectionSnapTextTitle {
            width: 190px;
            height: 40px;
            overflow: hidden;
        }

        /* Text line 2 */
        .imageTextListCollectionSnap .imageTextListCollectionSnapText .imageTextListCollectionSnapTextDescription {
            overflow: hidden;
        }

/* style the focus visual for edge-to-edge items */
#imageTextListCollectionSnap .win-focusedoutline {
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    left: 2px;
    top: 2px;
    z-index: 5;
}

相关主题

网格布局的项模板

列表布局的项模板