如何在Code中设置背景图像Stretch和TileMode?

时间:2011-02-28 13:50:09

标签: c# imagebrush

使用C#,如何设置背景图像的TileMode和Stretch属性?

  

StackPanel1.Background = new ImageBrush(new ....); // OK
  StackPanel1.Background = Stretch.Uniform; //this doesn't work...

1 个答案:

答案 0 :(得分:2)

需要在图像画笔本身上设置属性。

var imageBrush = new ImageBrush();
imageBrush.Stretch = Stretch.Uniform;
StackPanel1.Background = imageBrush;