StretchDirection Property
Collapse the table of content
Expand the table of content

Image.StretchDirection Property


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

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public StretchDirection StretchDirection { get; set; }

Property Value

Type: System.Windows.Controls.StretchDirection

One of the StretchDirection values. The default is Both.

The following example demonstrates how to use this property.

Dim myImage1 As New Image()

' Set the stretch property.
myImage1.Stretch = Stretch.Fill

' Set the StretchDirection property.
myImage1.StretchDirection = StretchDirection.Both

' Create source
Dim myBitmapImage1 As New BitmapImage()

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

'set image source
myImage1.Source = myBitmapImage1

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft