Creating a transparent background in WPF

I have a button with a background image in white. My button sits on a toolbar that is blue. When the button sits on the toolbar, the button looks white, however I want it to look blue because the background color of the toolbar is blue.

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

+3
source share
3 answers

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

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

Where Opacity can be any value from 0 to 1.

EDIT. , "". , ? , , :

<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>
+6

System.Windows.Media.Color Transparent, :

<Button Background="Transparent" />
+3

You need to make sure your image is transparent, WPF will not try to figure out which parts of your image should be transparent and which parts should be opaque. Make sure your image editor can export images with transparency, most likely in PNG.

+2
source

Source: https://habr.com/ru/post/1739413/


All Articles