Stretch 列舉

定義

描述如何調整內容大小以填滿其配置空間。

public enum class Stretch
public enum Stretch
type Stretch = 
Public Enum Stretch
繼承

欄位

Fill 1

內容會調整大小以填滿目的尺寸。 不會保留長寬比。

None 0

內容會保留其原始大小。

Uniform 2

內容會調整大小以符合目的尺寸,同時也會保留其原始長寬比。

UniformToFill 3

內容會調整大小以填滿目的尺寸,同時也會保留其原始長寬比。 如果目的矩形的長寬比與來源不同,則會裁剪來源內容使其符合目的尺寸。

範例

下列範例示範如何使用程式碼建立 的 Viewbox 實例,並設定 Stretch 其內容的模式。


// Create a Viewbox and add it to the Canvas
myViewbox = gcnew Viewbox();
myViewbox->StretchDirection = StretchDirection::Both;
myViewbox->Stretch = Stretch::Fill;
myViewbox->MaxWidth = 400;
myViewbox->MaxHeight = 400;

// Create a Viewbox and add it to the Canvas
myViewbox = new Viewbox();
myViewbox.StretchDirection = StretchDirection.Both;
myViewbox.Stretch = Stretch.Fill;
myViewbox.MaxWidth = 400;
myViewbox.MaxHeight = 400;

' Create a ViewBox and add it to the Canvas
Dim myViewbox As New Viewbox()
myViewbox.StretchDirection = StretchDirection.Both
myViewbox.Stretch = Stretch.Fill
myViewbox.MaxWidth = 400
myViewbox.MaxHeight = 400

備註

下圖顯示不同的 Stretch 值。

不同的 TileBrush Stretch 設定不同的
延展值

適用於