Image.Stretch Właściwość

Definicja

Pobiera lub ustawia wartość, która opisuje, jak Image należy rozciągnąć, aby wypełnić prostokąt docelowy.

public:
 property System::Windows::Media::Stretch Stretch { System::Windows::Media::Stretch get(); void set(System::Windows::Media::Stretch value); };
public System.Windows.Media.Stretch Stretch { get; set; }
member this.Stretch : System.Windows.Media.Stretch with get, set
Public Property Stretch As Stretch

Wartość właściwości

Jedna z Stretch wartości. Wartość domyślna to Uniform.

Przykłady

W poniższym przykładzie pokazano, jak używać tej właściwości.

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

Uwagi

Wartość spowoduje Fill rozciągnięcie obrazu w celu całkowitego wypełnienia obszaru wyjściowego. Gdy obszar wyjściowy i obraz mają różne współczynniki proporcji, obraz jest zniekształcony przez to rozciąganie. Aby zachować Image współczynnik proporcji obrazu, ustaw tę właściwość na Uniform (wartość domyślna) lub UniformToFill.

Informacje dotyczące właściwości zależności

Pole identyfikatora StretchProperty
Właściwości metadanych ustawione na true AffectsMeasure

Dotyczy

Zobacz też