Image.Stretch property

Applies to Windows and Windows Phone

Gets or sets a value that describes how an Image should be stretched to fill the destination rectangle.

Syntax


public Stretch Stretch { get; set; }


<Image Stretch="stretchValue"/>

XAML Values

stretchValue

A named constant of the Stretch enumeration, such as Uniform.

Property value

Type: Stretch

A value of the Stretch enumeration that specifies how the source image is rendered, if the Height and/or Width of the Image are not explicitly specified. The default value is Uniform.

Remarks

The value of the Stretch property is only relevant if the Image instance is not already using explicitly set values for the Height and/or Width property, and if the Image instance is inside a container that can stretch the image to fill some available space in layout. If you set the value of the Stretch property to None, the image always retains its natural size, even if there's a layout container that might stretch it otherwise. For more info on image sizing, see Remarks in Image.

Image sources and scaling

You should create your image sources at several recommended sizes, to ensure that your app looks great when Windows 8 scales it because of device scaling and resolution. This is often a better way to handling image resizing rather than applying a nondefault Stretch value. When specifying a Source for an Image, you can use a naming convention that will automatically reference the correct resource for the current scaling. For specifics of the naming convention and more info, see Quickstart: Using file or image resources.

For more info on how to design for scaling, see Guidelines for scaling to pixel density.

Note  A Stretch value of None doesn't work for image resources that are intended to support scaling. The scaling will be detected and the appropriate scaled resource is loaded before the layout decisions implied by the None value are applied.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Image

 

 

Show:
© 2014 Microsoft