语言

Stretch 枚举

定义

描述如何调整内容的大小以填充其分配的空间。

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

字段

名称 值 说明
None 0

内容保留其原始大小。

Fill 1

调整内容的大小以填充目标维度。 不保留纵横比。

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 设置
拉伸值

适用于