Jaime Oro
Jaime Oro

Reputation: 10145

Set background to image control

I've an Image Control in a WPF Form. When there's no image loaded. I want to make it dark gray but all of the controls have the Background exept the Image control.

Does anybody knows how can I set a background to the image control in the XAML?

Upvotes: 12

Views: 20658

Answers (2)

kyrylomyr
kyrylomyr

Reputation: 12652

You can just surround your image with border:

<Border Height="300" Width="300" Background="Gray">
    <Image Stretch="Fill" />
</Border>

Upvotes: 27

ngduc
ngduc

Reputation: 1413

This is how I do it: use a PNG file as a background

<Image Source="Background.png" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

Upvotes: 1

Related Questions