Share via


Image (gallery) 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 in an image gallery. 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.

HTML

<!-- Item template -->
<div id="imageGalleryTemplate" 
     data-win-control="WinJS.Binding.Template">
  <div class="imageGallery">
    <img class="imageGalleryImage" 
         data-win-bind="src: imageUrl"/>
  </div>
</div>

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

CSS

/* overall list dimensions */
#imageGallery
{
    width: 1366px;
    height: 578px;
}

/*-------------------------------------------------------------------------------------------*/
/* image-gallery - used in Picker gallery */
/*-------------------------------------------------------------------------------------------*/
    /* starting margin */
    #imageGallery .win-horizontal.win-viewport .win-surface
    {
        margin: 0px 115px;
    }
    
    /* individual item dimensions */
    .imageGallery
    {
        width: 190px;
        height: 130px;
        overflow: hidden;
    }

        /* image */
        .imageGallery img.imageGalleryImage
        {
            width: 190px;
            height: 130px;
            overflow: hidden;
        }

Item templates for grid layouts

Item templates for list layouts