半透明背景的文本框 [英] Textbox with Semi-Transparent Background

查看:36
本文介绍了半透明背景的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Textbox需要半透明背景,文本内容正常显示.

Semi-Transparent background of the Textbox is needed, and the text content should be shown as normal.

StyleBrush 可以存储在资源字典中.

Style or Brush which can store in the Resource dictionary is good.

注意:

  1. 我的文本框包含在一个 ContentControl 中.

  1. My textBox is wrapped within a ContentControl.

这个类似的问题没有帮助.​​具有透明背景的文本框.

This similar question does not help. TextBox with a Transparent Background .

推荐答案

在 XAML 中,您可以将 Background 属性设置为 Transparent:

In XAML you can set Background property to Transparent:

<TextBox Background="Transparent" />

在代码隐藏中,您可以使用以下代码:

In code-behind you can use following code:

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

如果要将背景设置为对所有 TextBox 透明,可以使用以下样式:

If you want to set background to transparent to all TextBox you can use following style:

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

这篇关于半透明背景的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆