Image.StretchDirection Property
Gets or sets a value that indicates how the image is scaled.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object StretchDirection="StretchDirection" .../>
Property Value
Type: System.Windows.Controls.StretchDirectionOne of the StretchDirection values. The default is Both.
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 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.