【发布时间】:2014-01-30 23:02:23
【问题描述】:
如何以编程方式使用 System.Drawing.Color 设置 WPF 文本块的背景和前景属性?没有转换器的解决方案会很好。
System.Drawing.Color BackColor = System.Drawing.Color.Black;
System.Drawing.Color ForeColor = System.Drawing.Color.White;
TextBlock txt = new TextBlock ();
txt.Background=BackColor ;
txt.ForeGround=ForeColor ;
PS:我要分配的颜色将来自 Windows 窗体应用程序 因此它将是 System.Drawing.Color 而不是 WPF 要求的 System.Windows.Media.Color。
【问题讨论】:
标签: c# .net wpf silverlight xaml