基本上,我有一个按钮,在按下时,应该改变另一个标签的文本颜色。但是,每当我尝试运行它,我得到的错误:'标签'不包含'ForeColor'的定义。
'Label' does not contain a definition for 'ForeColor' and no extension method 'ForeColor' accepting a first argument 'Label' could be found (are you missing a using directive or an assembly reference?)
的基本代码是:
private void Button_Click(object sender, RoutedEventArgs e)
{
tlabel.ForeColor = System.Drawing.Color.Red;
}
我该怎么办?
很抱歉,如果这个问题可能很容易可以解决的,但我只是最近才开始用C#,我无法找到解决我的问题(这甚至是相似或问题)的任何解决方案。
不要混淆的WinForms WPF,它们是*非常*不同的GUI类库。请务必让你在成功的坑属于智能感知弹出帮助,它会打你的牙齿和指甲从键入“前景色”阻止你。 –
在这种情况下你应该做的一件事就是参考Label类的文档。在查看这些属性后,这将是相当明显的。 –