使用C#,如何设置背景图像的TileMode和Stretch属性?
StackPanel1.Background = new ImageBrush(new ....); // OK
StackPanel1.Background = Stretch.Uniform; //this doesn't work...
答案 0 :(得分:2)
需要在图像画笔本身上设置属性。
var imageBrush = new ImageBrush();
imageBrush.Stretch = Stretch.Uniform;
StackPanel1.Background = imageBrush;