渐变背景图像 [英] Background image over gradient

查看:46
本文介绍了渐变背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张带有透明背景的图像,我想将其作为所有控件后面的图像叠加在我的窗口上.

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.

这是不起作用的 XAML.你有什么建议?也许还有另一种设置图像的方法.

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>

推荐答案

您可以将 Image 控件进入顶层 Grid,位于所有其他控件之下:

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>

这篇关于渐变背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆