Export (0) Print
Expand All

Image.StretchDirection Property

Gets or sets a value that indicates how the image is scaled. This is a dependency property.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public StretchDirection StretchDirection { get; set; }
/** @property */
public StretchDirection get_StretchDirection ()

/** @property */
public void set_StretchDirection (StretchDirection value)

public function get StretchDirection () : StretchDirection

public function set StretchDirection (value : StretchDirection)

<object StretchDirection="StretchDirection" .../>

Property Value

One of the StretchDirection values. The default is Both.

Identifier field

StretchDirectionProperty

Metadata properties set to true

AffectsMeasure

The following example demonstrates how to use this property.

Image myImage1 = new Image();

// Set the stretch property.
myImage1.Stretch = Stretch.Fill;

// Set the StretchDirection property.
myImage1.StretchDirection = StretchDirection.Both;

// Create source
BitmapImage myBitmapImage1 = new BitmapImage();

// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage1.BeginInit();
myBitmapImage1.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg");
myBitmapImage1.EndInit();

//set image source
myImage1.Source = myBitmapImage1;

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

ADD
Show:
© 2014 Microsoft