更改WP7中的重点文本框背景/前景 [英] Change focused textbox background/foreground in WP7

查看:51
本文介绍了更改WP7中的重点文本框背景/前景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当文本框处于焦点位置时,文本的边框和前景都会根据当前主题进行更改:

Whenever the textbox is focused, the border and foreground of the text is changed according to the current theme:

主题灯->边框:黑色,文本:白色,背景:透明

theme light ->border:black, text:white, background:transparent

主题深色->边框:白色,文本:白色,背景:白色

theme dark ->border:white, text:white, background:white

我希望文本框始终具有border:white,text:white,background:transparent

I want the textbox always have border:white, text:white, background:transparent

当文本框没有聚焦时,我可以控制这些设置,但是当文本框聚焦时,我不能更改背景.

I can control these settings when the textbox is not focused, but I cannot change background when it has focus.

文本框的XML为:

<TextBox    InputScope="EmailSmtpAddress" Height="72" LostFocus="textBox1_LostFocus"  GotFocus="textBox1_GotFocus" HorizontalAlignment="Left" Margin="0,62,0,0" Name="textBox1" Text="Enter URL here..." VerticalAlignment="Top" Width="460" TextChanged="textBox1_TextChanged" Foreground="White" Background="#005DADF5" SelectionForeground="White" BorderBrush="#DEEAEAEA" FontFamily="Tahoma" FontWeight="Normal" />

推荐答案

显然,当焦点对准文本框时,您无法更改其背景,而不是在黑暗主题下更改(甚至类似于系统的集成文本框中的背景).

Apparently you cannot change the background of textbox when it gets focused, not in dark theme (It's even like that in the integrated textboxes of the system).

所以我想出了一个解决我问题的解决方案,

So I came up with a solution that solved my problem,

我创建了两个彼此完全相同的文本框实例,并将前一个的不透明度更改为等于0(完全不可见).

I created two textbox instances Exactly above each other, and change the Opacity of the front one to be equal 0 (completely invisible).

然后,我通过代码连接了两个文本框,因此如果要键入前一个文本框(它是不可见的,所以没人会看到正在写的文本),我将后一个文本框的文本编辑为完全相同.

Then I connected both textboxes through code so that if the front one is being typed into (it's invisible so no one will see the text being written) I edit the text of the back one to be exactly the same.

这篇关于更改WP7中的重点文本框背景/前景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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