I have a TextBox
:
<TextBox x:Name="myTextBox"/>
The TextBox
in code behind has two booleans:
myTextBox.Background.Opacity = 0; myTextBox.BorderBrush.Opacity = 0;
Now this is all good and dandy, but how do I set these two properties in XAML?
Btw, setting:
<TextBox x:Name="myTextBox" Background="#00FFFFFF"/>
Does not effect the Opacity
property. I'd like to specifically set that opacity property in XAML.
Opacity in XAML is defined as a double, not an HTML color triplet. http://msdn.microsoft.com/en-us/library/system.windows.uielement.opacity.aspx. You'll want to set it like this: <TextBlock Opacity="0" /> You can also use a brush to set it: <SolidColorBrush Color="#FF295564" Opacity="0.3"/>
All WPF controls are inherited from UIElement. The Opacity property of UIElement is used to set transparency of a control. The value of Opacity falls between 0.0 and 1.0 where 0.0 is fully transparent and 1.0 is fully opaque.
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}" />
You want to do something like this:
<TextBlock Text="foo bar"> <TextBlock.Background> <SolidColorBrush Color="Azure" Opacity="0.5" /> </TextBlock.Background> </TextBlock>
Opacity in XAML is defined as a double, not an HTML color triplet.
http://msdn.microsoft.com/en-us/library/system.windows.uielement.opacity.aspx
You'll want to set it like this:
<TextBlock Opacity="0" />
You can also use a brush to set it:
<SolidColorBrush Color="#FF295564" Opacity="0.3"/>
...and then set the background property to your brush.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With