Image.StretchDirection 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示如何缩放图像。
public:
property System::Windows::Controls::StretchDirection StretchDirection { System::Windows::Controls::StretchDirection get(); void set(System::Windows::Controls::StretchDirection value); };
public System.Windows.Controls.StretchDirection StretchDirection { get; set; }
member this.StretchDirection : System.Windows.Controls.StretchDirection with get, set
Public Property StretchDirection As StretchDirection
属性值
StretchDirection 值之一。 默认值为 Both。
示例
下面的示例演示如何使用此属性。
Image myImage1 = new Image();
// Set the stretch property.
myImage1.Stretch = Stretch.Fill;
// Set the StretchDirection property.
myImage1.StretchDirection = StretchDirection.Both;
// Create source
BitmapImage myBitmapImage1 = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage1.BeginInit();
myBitmapImage1.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg");
myBitmapImage1.EndInit();
//set image source
myImage1.Source = myBitmapImage1;
Dim myImage1 As New Image()
' Set the stretch property.
myImage1.Stretch = Stretch.Fill
' Set the StretchDirection property.
myImage1.StretchDirection = StretchDirection.Both
' Create source
Dim myBitmapImage1 As New BitmapImage()
' BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage1.BeginInit()
myBitmapImage1.UriSource = New Uri("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg")
myBitmapImage1.EndInit()
'set image source
myImage1.Source = myBitmapImage1
注解
依赖项属性信息
标识符字段 | StretchDirectionProperty |
元数据属性设置为 true |
AffectsMeasure |