本文介绍了我正在尝试更改前景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试在运行时设置Textbox控件的颜色,如
TextBox1.Foreground = Brush.White;
我收到错误消息:"System.Windows.Media.Brush"不包含"White"的定义
代码为:
Hi all,
I am trying to set the Textbox control''s color in runtime like;
TextBox1.Foreground = Brush.White;
I get an Error: ''System.Windows.Media.Brush'' Does not contain a difinition for ''White''
The Code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Threading;
namespace Test1
{
public partial class MainPage : PhoneApplicationPage
{
private DispatcherTimer _timer;
public MainPage()
{
InitializeComponent();
}
public void RefreshUI(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
if (dt.Day == 1)
{
TextBox1.Foreground = Brush.White;
}
}
}
}
在此先谢谢您.
Thanks in advance.
推荐答案
这篇关于我正在尝试更改前景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!