Fernando Sousa
Fernando Sousa

Reputation: 241

How to have transparent background for button?

I am develop na UWP app, and I would like to have a transparent button. I try this (Is a simple example of my button):

<Button Name="Button"
        Opacity="0">
        <Image Source="/Assets/image.png"/>
</Button>

I want a button with an image, in which only the button is transparent. I've tried it that way, and by putting: Opacity="0" it puts everything transparent, and I want it to just be transparent.

Upvotes: 3

Views: 5063

Answers (1)

Vijay Nirmal
Vijay Nirmal

Reputation: 5857

Method 1

Set Opacity="0" for Button.Background. You can do it by using below code.

<Button>
    <Button.Background>
        <SolidColorBrush Opacity="0"/>
    </Button.Background>
</Button>

Method 2

Set #00000000 as the background color of the Button. Since UWP support ARGB(Alpha RGB) color you can directly set opacity for any color in UWP app.

<Button Background="#00000000"/>

Upvotes: 9

Related Questions