Transparent Background of a Control in WPF

Recently, I had to create some transparent controls in WPF.

When you create a control such as a Button in WPF and you do not set any Background property, it has a default background property. The default property of the control is inherited from the Windows Control set on your machine.

For example, the following code snippet creates a Button control. 

<Button Name="Button1" Height="30" Width="200" BorderBrush="Black"

                Content="Click Me!"/>

The Button control looks like this:

Transparent-Button-in-WPF.jpg

What if you want to set a Button control's background transparent?

You can set a control's background transparent by setting the Background property to null, using the following code:

<Button Name="Button1" Height="30" Width="300" BorderBrush="Yellow" Background="{x:Null}" />

The new Button control looks like this:

Transparent-Control-in-WPF.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all