Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Stretch Enumeration

Describes how content is resized to fill its allocated space.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public enum Stretch
public enum Stretch
public enum Stretch
<object property="EnumerationValue" .../>

 Member nameDescription
FillThe content is resized to fill the destination dimensions. The aspect ratio is not preserved.  
NoneThe content preserves its original size.  
UniformThe content is resized to fit in the destination dimensions while it preserves its native aspect ratio.  
UniformToFillThe 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. 

The following illustration shows the different Stretch values.

Stretch values


Different TileBrush Stretch settings

The following example shows how to create an instance of a Viewbox and set the Stretch mode of its content by using code.


// Create a Viewbox and add it to the Canvas
myViewbox = new Viewbox();
myViewbox.StretchDirection = StretchDirection.Both;
myViewbox.Stretch = Stretch.Fill;
myViewbox.MaxWidth = 400;
myViewbox.MaxHeight = 400;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2014 Microsoft