Stretch属性

Cited from Microsoft Help:

The Stretch property accepts the following values, which the Stretch enumeration defines:

  • None: The TileBrush content does not stretch to fill the tile.

  • Uniform: The TileBrush content is scaled to fit the tile dimensions. However, the aspect ratio of the content is preserved.

  • UniformToFill: The TileBrush content is scaled so that it completely fills the output area but preserves its original aspect ratio.

  • Fill: The TileBrush content is scaled to fit the tile. Because the content's height and width are scaled independently, the original aspect ratio of the content might not be preserved. That is, the TileBrush content might be distorted in order to completely fill the output tile.

The following image illustrates the different Stretch settings.

By default, an ImageBrush stretches its image to completely fill the area that you are painting. (即Stretch属性的默认值为“Fill”)

 

自解:

Stretch属性类似于电脑桌面背景的设置,具有该属性的有Image控件、ImageBrush类等。

  • None   源图像不拉伸,以原始尺寸填充其容器
  • Uniform   源图像等比例拉伸,以填充其容器
  • UniformToFill   源图像等比例拉伸,以填充其容器
  • Fill   源图像非等比例拉伸,以填充其容器

详解:

  • None   图像不膨胀(尺寸不变):图像和容器左上顶点对齐,容器右、下边框对图像右、下部分进行裁剪。如果图像尺寸小于容器尺寸,则哪边小哪边就居中
  • Uniform   图像等比例“膨胀”:“图像点”从容器中心处开始等比例“膨胀”,直至图像某对边缘第一次触及容器边框,膨胀停止(无论容器是否被填满)
  • UniformToFill   图像等比例“膨胀”:“图像点”从容器中心处开始等比例“膨胀”,当图像某对边缘第一次触及容器边框,若此时容器未被填满,则膨胀继续,直至图像另一对边缘触及容器边框,膨胀停止(此时容器被填满)
  • Fill   图像非等比例“膨胀”:“图像点”从容器中心处开始非等比例“膨胀”,当且仅当某对边缘触及容器边框时,该对边缘才停止膨胀,否则膨胀继续
posted @ 2017-07-24 15:03  Avin  阅读(2090)  评论(0编辑  收藏  举报