Stretch Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Describes how content is resized to fill its allocated space.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Enumeration Stretch
public enum Stretch
<object property="enumMemberName"/>

Members

Member name Description
Supported by Silverlight for Windows Phone None The content preserves its original size.
Supported by Silverlight for Windows Phone Fill The content is resized to fill the destination dimensions. The aspect ratio is not preserved.
Supported by Silverlight for Windows Phone Uniform The content is resized to fit in the destination dimensions while it preserves its native aspect ratio.
Supported by Silverlight for Windows Phone UniformToFill The content is resized to fill the destination dimensions while it preserves its native aspect ratio. If the aspect ratio of the destination rectangle differs from the source, the source content is clipped to fit in the destination dimensions.

Remarks

The following illustration shows the different Stretch values. Keep in mind that different Panel containers and different layout properties (such as VerticalAlignment and HorizontalAlignment) can affect the final rendering. This illustration is of an Image object in a Grid with VerticalAlignment and HorizontalAlignment set to Center.

Stretch values

Stretch values.

NoteNote:

Although unintuitive, in some cases you can get better performance by setting Stretch properties to Fill instead of other values, including None. When you use Stretch = Fill, there is no potential clipping happening which adds extra edges. Any other type of stretch besides Fill needs to compute layout (e.g. compute centering). You will probably not notice the difference unless you are rendering a lot of images.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference