[英]WPF C# TextBlock. How to format textblock text programatically to format foreground color of certain words that are color names
[英]How to add multiple properties in a Textblock programatically using WPF & c#?
如何使用 c# 代码向 WPF 中的文本块中的特定文本添加多个属性,在本例中为Foreground
和FontSize
?
我试过像下面那样做,但出现错误
mytxtblock.Inlines.Clear();
mytxtblock.Inlines.Add(new Run("Bills pending for Processing: ") { Foreground = Brushes.Aquamarine });
mytxtblock.Inlines.Add(new Run(pendingBills.ToString()) { Foreground = Brushes.LimeGreen } { FontSize = 13 });
帮助 !
有一件事是语法错误
代替
mytxtblock.Inlines.Add(
new Run(pendingBills.ToString())
{
Foreground = Brushes.LimeGreen
}
{
FontSize = 13
});
你必须使用
mytxtblock.Inlines.Add(
new Run(pendingBills.ToString())
{
Foreground = Brushes.LimeGreen,
FontSize = 13
});
每当您询问时,您还应该描述错误消息本身。 我不知道这是您的复制/粘贴错误还是您遇到的真正问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.