Im attempting to make textbox text somewhat transparent. I've linked an example picture to help explain what i'm talking about.
So far i've tried to edit the opacity of the text box, however this will cause the entire textbox to become transparent instead of just the text.
What can i use to achieve this?
Asked
Active
Viewed 1,976 times
0

asa
- 47
- 7
-
Try setting the alpha channel of the [`.Foreground`](https://msdn.microsoft.com/en-us/library/system.windows.controls.control.foreground(v=vs.110).aspx) property – maccettura Apr 25 '18 at 21:03
-
I think the correct terminology for the thing you want to do is called a "watermark". If that is what you are looking for this question is a duplicate of [Watermark / hint text / placeholder TextBox in WPF](https://stackoverflow.com/questions/833943/watermark-hint-text-placeholder-textbox-in-wpf) – Scott Chamberlain Apr 25 '18 at 21:05
-
@maccettura Sounds like a good idea. Once the user starts entering input I can set it back to a more visible text. Thanks – asa Apr 25 '18 at 21:07
1 Answers
1
The .Foreground
property of a TextBox is a Brush
, Brush has a property called .Opacity
. You should be able to do something like this:
someTextBox.Foreground?.Opacity = 0.50;

maccettura
- 10,514
- 3
- 28
- 35