語言

Stretch 列舉

定義

描述如何重設大小以填滿其配置的空間。

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

欄位

名稱 值 Description
None 0

內容保留原始大小。

Fill 1

內容會被調整大小以填滿目的地的維度。 畫面比例未被保留。

Uniform 2

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

UniformToFill 3

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

範例

以下範例展示了如何透過程式碼建立 a 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 拉伸設定
伸展值

適用於