Skip to content

Latest commit

 

History

History
35 lines (35 loc) · 1.01 KB

HOW-TO.md

File metadata and controls

35 lines (35 loc) · 1.01 KB
nav-title title description
Image How-To
How-To
Examples for using Image

Image

Using an image requires the Image module to be loaded.

var ImageModule = require("ui/image");

Binding the image source property to a view-model property.

<Page>
  {%raw%}<Image source="{{ thumbnailImageSource }}" />{%endraw%}
</Page>

How to create an image and set its source.

var image = new ImageModule.Image();
image.source = ImageSourceModule.fromResource("logo");

How to create an image and set its url.

var image = new ImageModule.Image();
image.url = "https://www.google.bg/images/srpr/logo11w.png";

How to set image stretching.

var image = new ImageModule.Image();
image.source = ImageSourceModule.fromFile(imagePath);
// There are 4 modes of stretching none, fill, aspectFill, aspectFit
// The default value is aspectFit.
// Image stretch can be set by using ImageModule.stretch enum.
image.stretch = enumsModule.Stretch.aspectFit;