WPF图片背景平铺

ImageBrush中的TileMode、Viewport属性可以实现平铺。

1 <Grid>
2          <Grid.Background>
3                 <ImageBrush ImageSource="Res/Images/curcattab.png" TileMode="Tile"  Viewport="0,0,0.5,0.5"/>
4          </Grid.Background>
5 </Grid>
View Code

就是imageBrush从坐标(0,0)到(0.5,0.5)实现平铺4张图,因为坐标从(0,0)到(1,1)是全屏,所以到0.5是一半,就显示4张图片,如果Viewport设置成"0,0,0.1,0.1",那么横向纵向就显示10张图片平铺。

参考:http://bbs.csdn.net/topics/340191709

原文地址:https://www.cnblogs.com/duqingsong/p/3090713.html