Image.Stretch プロパティ

定義

Image を表示先の四角形全体に引き伸ばす方法を表す値を取得または設定します。

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

プロパティ値

Stretch 値のいずれか 1 つ。 既定値は、Uniform です。

次の例では、このプロパティを使用する方法を示します。

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

注釈

Fill 値を指定すると、イメージが拡大され、出力領域が完全に塗りつぶされます。 出力領域とイメージの縦横比が異なる場合は、この引き伸ばしによってイメージがゆがめられます。 イメージの縦横比を Image 保持するには、このプロパティを (既定値) または に Uniform 設定します UniformToFill

依存プロパティ情報

識別子フィールド StretchProperty
に設定されたメタデータ プロパティ true AffectsMeasure

適用対象

こちらもご覧ください