Image.StretchDirection Propiedad

Definición

Obtiene o establece un valor que indica cómo va a ajustarse la imagen.

C#
public System.Windows.Controls.StretchDirection StretchDirection { get; set; }

Valor de propiedad

StretchDirection

Uno de los valores de StretchDirection. De manera predeterminada, es Both.

Ejemplos

En el ejemplo siguiente se muestra cómo usar esta propiedad.

C#
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;

Comentarios

Información sobre propiedades de dependencia

Campo identificador StretchDirectionProperty
Propiedades de metadatos establecidas en true AffectsMeasure

Se aplica a

Producto Versiones
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Consulte también