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. 

  1. <Button Name="Button1" Height="30" Width="200" BorderBrush="Black"  
  2.                 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:

  1. <Button Name="Button1" Height="30" Width="300" BorderBrush="Yellow" Background="{x:Null}" />  
The new Button control looks like this:

Transparent-Control-in-WPF.jpg


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.