我有一个用户控件,我想在其中添加一个图像作为背景。我正在使用此代码:
<UserControl.Background> <ImageBrush ImageSource="x:\myLogo.png"/> </UserControl.Background>
问题是我找不到缩放图像的方法,因为它填充了用户控件,不保持比例。我找不到任何方法来缩放和设置图像的其他属性,除了不透明度。
那么,如何缩放和设置图像的填充选项呢?
谢谢。
imagebrush has the stretch property to define how to fit the content using the Stretch Enumeration :”
stretch property to define how to fit the content using the
property to define how to fit the content using the
Stretch Enumeration :”
描述如何调整内容大小以填充其分配的空间 <imagebrush imagesource=”../image.jpg“stretch=”uniform“/> StretchStretch enumeration 描述如何调整内容大小以填充其分配的空间 <ImageBrush ImageSource="../Image.jpg"/> <ImageBrush ImageSource="../Image.jpg" Stretch="None"/> <ImageBrush ImageSource="../Image.jpg" Stretch="Uniform"/> <ImageBrush ImageSource="../Image.jpg" Stretch="UniformToFill"/> Viewbox和Viewportthis tutorial
描述如何调整内容大小以填充其分配的空间
<imagebrush imagesource=”../image.jpg“stretch=”uniform“/> StretchStretch enumeration 描述如何调整内容大小以填充其分配的空间 <ImageBrush ImageSource="../Image.jpg"/> <ImageBrush ImageSource="../Image.jpg" Stretch="None"/> <ImageBrush ImageSource="../Image.jpg" Stretch="Uniform"/> <ImageBrush ImageSource="../Image.jpg" Stretch="UniformToFill"/> Viewbox和Viewportthis tutorial
<imagebrush imagesource=”../image.jpg“stretch=”uniform“/>
StretchStretch enumeration 描述如何调整内容大小以填充其分配的空间 <ImageBrush ImageSource="../Image.jpg"/> <ImageBrush ImageSource="../Image.jpg" Stretch="None"/> <ImageBrush ImageSource="../Image.jpg" Stretch="Uniform"/> <ImageBrush ImageSource="../Image.jpg" Stretch="UniformToFill"/> Viewbox和Viewportthis tutorial
Stretch
<ImageBrush ImageSource="../Image.jpg"/>
<ImageBrush ImageSource="../Image.jpg" Stretch="None"/>
<ImageBrush ImageSource="../Image.jpg" Stretch="Uniform"/>
<ImageBrush ImageSource="../Image.jpg" Stretch="UniformToFill"/>
Viewbox和Viewportthis tutorial