建立在WPF透明背景 [英] Creating transparent background in WPF

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

问题描述

我有一个白色的背景和图像的按钮。我的按钮,坐在里面有蓝色的bacground颜色在工具栏上。当按钮被坐在在工具栏上的按钮看起来是白色的,但我希望它看起来像蓝为工具栏的背景颜色为蓝色。

I have a button with a backgroun image of color white. My button is sitting on the toolbar which has a bacground color of Blue. When the button is sitting on the toolbar, the button looks white, however I want it to look like blue as the the background color of toolbar is Blue.

我应该如何在WPF实现这一目标。请让我知道。

How should I achieve this in WPF.. Please let me know.

推荐答案

您确定要使用的图像?如果图像只是一个纯色,你可能会更好过只是按钮的背景设置为白色,并调整其不透明度。像:

Are you sure you want to use an image? If the image is just a solid color, you're probably better off just setting the button's background to white and adjusting its opacity. Like:

<Button Background="White" Opacity="0.5" />

其中不透明度可以是0和1之间的任何值。

Where Opacity can be any value between 0 and 1.

修改:我不知道你的意思是阴影。您是否知道,你可以设置一个按钮,以渐变的背景是什么?你想改变我敢肯定的颜色,但它会是这个样子:

EDIT: I'm not sure what you mean by "shades." Are you aware that you can set the background of a Button to a gradient? You'll want to change the colors I'm sure, but it will look something like this:

<Button>
    <Button.Background>
        <LinearGradientBrush>
            <GradientStop Color="Yellow" Offset="0.0" />
            <GradientStop Color="Orange" Offset="0.5" />
            <GradientStop Color="Red" Offset="1.0" />
         </LinearGradientBrush>
    <Button.Background>
</Button>

这篇关于建立在WPF透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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