Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image over gradient

Tags:

wpf

xaml

I have an image with a transparent background which I would like to overlay on my window as an image behind all of the controls.

My window background already has a gradient brush, but what I can tell by Googling and experimenting, you cannot have two background brushes.

Here is the XAML which isn't working. What do you suggest? Maybe there is another way of setting the image.

<Window.Background>
    <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
        <GradientStop Color="#FFF7F7F7"/>
        <GradientStop Color="White" Offset="1"/>
    </LinearGradientBrush>
    <ImageBrush ImageSource="/Images/Arrow.png">
    </ImageBrush>
</Window.Background>
like image 884
rhughes Avatar asked May 06 '26 15:05

rhughes


1 Answers

You may put an Image control into a top-level Grid, below all other controls:

<Grid>
    <Grid.Background>
        <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
            <GradientStop Color="#FFF7F7F7"/>
            <GradientStop Color="White" Offset="1"/>
       </LinearGradientBrush>
    </Grid.Background>
    <Image Source="/Images/Arrow.png">
    <Grid>
        ... all other controls go here
    </Grid>
</Grid>
like image 69
Clemens Avatar answered May 11 '26 06:05

Clemens