How to set Background image's Scretch and TileMode in Code behind?

1.9k views Asked by At

Using C#, how to set the Background image's TileMode and Stretch property?

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

1

There are 1 answers

0
Spruce On BEST ANSWER

Need to set the property on the image brush itself.

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