Gets or sets a value that describes how an Image should be stretched to fill the destination rectangle.
Assembly: PresentationFramework (in PresentationFramework.dll)
A value of Fill will cause your image to stretch to completely fill the output area. When the output area and the image have different aspect ratios, the image is distorted by this stretching. To make an Image preserve the aspect ratio of the image, set this property to Uniform (default) or UniformToFill.
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.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
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0