简体   繁体   English

WPF使文本框文本透明

[英]WPF make textbox text transparent

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? 我可以用什么来实现这一目标? 在此处输入图片说明

The .Foreground property of a TextBox is a Brush , Brush has a property called .Opacity . TextBox的.Foreground属性是Brush ,Brush具有一个名为.Opacity的属性。 You should be able to do something like this: 您应该能够执行以下操作:

someTextBox.Foreground?.Opacity = 0.50;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM