Udostępnij za pośrednictwem


Image and text list (collection snap) template (HTML)

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Defines an item for a snapped view that contains an icon, a larger, bold heading, a smaller subheading, and descriptive text. This template is for use with a ListView that has a list layout. For additional templates, see Item templates for grid layouts and Item templates for list layouts.

To use the template

To use the template, copy the HTML and the CSS styles into your project. The HTML includes a ListView that's designed to be used with the template. After you copy the HTML, set the ListView control's itemDataSource to your app's data source and update the template's data-win-bind attributes so they work with your data.

For the template to work properly, assign the win-selectionstylefilled class to your 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;
}

Item templates for grid layouts

Item templates for list layouts