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に設定します。

依存関係プロパティ情報

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

適用対象

こちらもご覧ください