Text box with translucent background

A translucent background of the text field is necessary, and the text content should be displayed as usual.

A Style or Brush that can be stored in a resource dictionary is good.

Note:

+4
source share
2 answers

In XAML, you can set the Background property to Transparent :

 <TextBox Background="Transparent" /> 

In encoding, you can use the following code:

 TextBox tb = new TextBox { Width = 100, Background = Brushes.Transparent }; 

If you want the background to be transparent to all TextBox , you can use the following style:

 <Style TargetType="TextBox"> <Setter Property="Background" Value="Transparent" /> </Style> 
+13
source

If you want to set translucent background in encoding, you can do it

use dependency support over a class that inherits from TextBox

 public static readonly DependencyProperty BgColourProperty = DependencyProperty.Register("BgColour", typeof(SolidColorBrush), typeof(myTextBox), null); public SolidColorBrush BgColour { get { return (SolidColorBrush)GetValue(BgColourProperty); } set { SetValue(BgColourProperty, value); } } 

then set whatever color you want using Color.FromArgb (), where the 1st argument is an Alpha component

 myTextBox.BgColour = new SolidColorBrush(Color.FromArgb(120,240, 17, 17)); 
+1
source

All Articles