共用方式為


影像與文字清單 (集合貼齊) 範本 (HTML)

[ 本文的目標對象是撰寫 Windows 執行階段 App 的 Windows 8.x 和 Windows Phone 8.x 開發人員。如果您正在開發適用於 Windows 10 的 App,請參閱 最新文件 ]

定義貼齊檢視的項目,包含圖示、較大粗體標題、較小次標題及描述性文字。 這個範本用來與具備清單配置的 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;
}

相關主題

格線配置的項目範本

清單配置的項目範本