KMC
KMC

Reputation: 20046

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

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...

Upvotes: 1

Views: 1906

Answers (1)

Spruce
Spruce

Reputation: 282

Need to set the property on the image brush itself.

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

Upvotes: 2

Related Questions