StretchDirection 枚举


描述如何对内容应用缩放,并限制对已命名像素类型的缩放。Describes how scaling applies to content and restricts scaling to named axis types.

public enum class StretchDirection
public enum StretchDirection
type StretchDirection = 
Public Enum StretchDirection


Both 2

内容根据 Stretch 模式进行拉伸以适合父项的大小。The content stretches to fit the parent according to the Stretch mode.

DownOnly 1

内容仅在大于父级时缩放。The content scales downward only when it is larger than the parent. 如果内容较小,则不会执行任何扩展。If the content is smaller, no scaling upward is performed.

UpOnly 0

内容仅在小于父级时扩展。The content scales upward only when it is smaller than the parent. 如果内容较大,则不执行缩放。If the content is larger, no scaling downward is performed.


下面的示例演示如何使用代码创建的实例ViewboxStretchDirection设置内容。The following example shows how to create an instance of Viewbox and set the StretchDirection of 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