Stretch 枚举

定义

描述如何调整内容大小以填充为其分配的空间。Describes how content is resized to fill its allocated space.

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

字段

Fill 1

调整内容大小以填充目标尺寸。The content is resized to fill the destination dimensions. 不保留纵横比。The aspect ratio is not preserved.

None 0

内容保持其原始大小。The content preserves its original size.

Uniform 2

在保留内容原有纵横比的同时调整内容的大小,以适合目标尺寸。The content is resized to fit in the destination dimensions while it preserves its native aspect ratio.

UniformToFill 3

在保留内容原有纵横比的同时调整内容的大小,以填充目标尺寸。The content is resized to fill the destination dimensions while it preserves its native aspect ratio. 如果目标矩形的纵横比不同于源矩形的纵横比,则对源内容进行剪裁以适合目标尺寸。If the aspect ratio of the destination rectangle differs from the source, the source content is clipped to fit in the destination dimensions.

示例

下面的示例演示如何使用代码创建的Viewbox实例并设置其内容的Stretch模式。The following example shows how to create an instance of a Viewbox and set the Stretch mode of its content by using code.


// 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的值。The following illustration shows the different Stretch values.

不同的 TileBrush 拉伸设置Different TileBrush Stretch settings
Stretch 值Stretch values

适用于