【发布时间】:2019-07-31 23:27:36
【问题描述】:
我在 WPF 中有标签的动态内容。当标签的文本发生更改时,如何更改标签的前景色,我有 Winform 的代码,但 WPF 需要它。 设计器端的 Winform 代码
this.lblSolar.Name= "lblSolar";
this.lblSolar.TextChanged + = new System.EventHandler(this.LblSolar_TextChanged);
text_Changed 函数代码
private void LblSolar_TextChanged(object sender, EventArgs e)
{
var solarCurrent= Convert.ToDouble(_sValues[(int)ValueOfRTC.SupplyCurrent]);
if (supplyCurrent < 1)
{
lblSupply.ForeColor= Color.Yellow;
}
else
{
// Assigning other colors.....
}
}
但我在 WPF XAML 中找不到“TextChanged”属性。那么解决方案是什么? 在此先感谢
【问题讨论】:
标签: c# wpf visual-studio winforms