Udostępnij za pośrednictwem


Icon and text (applications) 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 that represents an item. The item contains an icon and descriptive text. This template is for use with a ListView that has a grid 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="iconTextApplicationsTemplate" 
  data-win-control="WinJS.Binding.Template">
  <div class="iconTextApplications">
    <img class="iconTextApplicationsImage" data-win-bind="src: icon"/>
    <div class="iconTextApplicationsTitle" data-win-bind="innerText: largeText">
    </div>
  </div>
</div>
        
<!-- ListView -->
<div id="iconTextApplications"
    class="win-selectionstylefilled"
    data-win-control="WinJS.UI.ListView"
    data-win-options="{ itemDataSource: list.dataSource, 
        itemTemplate: select('#iconTextApplicationsTemplate'), 
        layout: { type: WinJS.UI.GridLayout } }">
</div>

CSS

/* overall ListView dimensions */
#iconTextApplications {
    width: 1366px;
    height: 558px;
}

/*-------------------------------------------------------------------------------------------*/
/* iconText-applications - used in Start search 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;
}

/* starting margin */
#iconTextApplications .win-horizontal.win-viewport .win-surface {
    margin: 0px 100px;
}

/* margin between items */
#iconTextApplications .win-container {
    margin: 0px 10px;
}

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

/* individual item dimensions */
.iconTextApplications {
    width: 210px;
    height: 50px;
    padding: 5px;
    overflow: hidden;
    display: -ms-grid;
}

    /* image: icon */
    .iconTextApplications img.iconTextApplicationsImage {
        width: 40px;
        height: 40px;
        margin: 5px;
        -ms-grid-column: 1;
    }

    /* text line 1 */
    .iconTextApplications .iconTextApplicationsTitle {
        overflow: hidden;
        margin: 5px;
        -ms-grid-column: 2;
    }

/* style the focus visual for edge-to-edge items */
#iconTextApplications .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