MediaElement.Stretch 属性

定义

获取或设置一个 Stretch 值,该值描述 MediaElement 如何填充目标矩形。

public:
 property System::Windows::Media::Stretch Stretch { System::Windows::Media::Stretch get(); void set(System::Windows::Media::Stretch value); };
public System.Windows.Media.Stretch Stretch { get; set; }
member this.Stretch : System.Windows.Media.Stretch with get, set
Public Property Stretch As Stretch

属性值

所呈现的媒体的拉伸值。 默认值为 Uniform

示例

以下示例演示如何创建 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 设置
不同的梯度分布方法

依赖项属性信息

标识符字段 StretchProperty
元数据属性设置为 true AffectsMeasure

适用于