Image.Stretch 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,這個值描述 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
屬性值
範例
下列範例示範如何使用這個屬性。
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 |