Sdílet prostřednictvím


Image.Stretch Property

Definition

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

public:
 property Stretch Stretch { Stretch get(); void set(Stretch value); };
Stretch Stretch();

void Stretch(Stretch value);
public Stretch Stretch { get; set; }
var stretch = image.stretch;
image.stretch = stretch;
Public Property Stretch As Stretch
<Image Stretch="stretchValue"/>

Property Value

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 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 Load images and assets tailored for scale.

For more info on how to design for scaling, see Introduction to Windows app design.

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.

Applies to