views:

391

answers:

3

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.

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

+1  A: 

You can use the System.Windows.Media.Color Transparent, like this:

<Button Background="Transparant" />
IanR
I tried this but doesn't help.. Is there any other mechanism?
Vin
+2  A: 

You have to make sure your image has transparency, WPF won't try to figure out what parts in your image should be see-through and what parts should be opaque. Check that your image editor can export images with transparency, most likely to PNG.

Simon Buchan
Do you know of any free tool that can do this? (for ex, Paint etc..)
Vin
@Vinjamuri - Paint.NET is free and can create png files. http://www.getpaint.net/
ChrisF
A: 

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" />

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>
oltman
I want to use an image because it has shades too..
Vin
See my edits above.
oltman