WindowsPhone如何更改文本框中文字的颜色?
文本框代码如下:
<TextBox Text="请输入注册邮箱" Foreground="White" Background="#BFB4ABAB" Name="EmailText" SelectionBackground="#BFB4ABAB" MouseLeftButtonDown="EmailText_Click" SelectionForeground="Black"/>
private void EmailText_Click(object sender, MouseButtonEventArgs e)
{
this.LoginName.Text = "";
this.LoginName.Foreground = new SolidColorBrush(Color.FromArgb(255,0,0,0));
//设置字体颜色为黑色
this.LoginName.SelectionBackground = new SolidColorBrush(Color.FromArgb(77, 108, 118, 255));
//设置文本颜色
}
private void EmailText_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (EmailText.Text=="请输入注册邮箱") //事件里写判断不然每点下都会清空文本
{
EmailText.Text = "";//清空文本
EmailText.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));//设置字体颜色
EmailText.SelectionBackground = new SolidColorBrush(Color.FromArgb(77, 108, 118, 255));//设置文本颜色
}
}