Paymon
Paymon

Reputation: 1213

UWP: Set both background color and image?

In a universal windows app, I need to set both background color and image (with some transparency) for a border element.

How can I create a brush that contains both? I have unsuccessfully tried using the Compositor class. But I can't figure it out.

Upvotes: 1

Views: 1868

Answers (2)

Tushar Raj Gupta
Tushar Raj Gupta

Reputation: 1

Surrounding the image with border helps in getting the background color in image.

<Border Background="Gray">
<Image Stretch="Fill" /></Border>

Upvotes: 0

Marian Dolinsk&#253;
Marian Dolinsk&#253;

Reputation: 3492

I'm not sure what you've been doing with that brushes, but you could just place the Grid above an Image and set an Opacity property of the Grid to value between 0.0 (hidden) and 1.0 (fully visible).

<Image Source="Assets/YourImage" />
<Grid Background="Black" Opacity="0.5">
    <!-- Your code here -->
</Grid>

Upvotes: 1

Related Questions