📜  如何从文本块 wpf 中的文本更改部分的颜色 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:54.286000             🧑  作者: Mango

代码示例1
1.
TextBlock textBlock = new TextBlock { Inlines = { new Run { Text = "some text: " }, new Run { Text = "some text", Foreground = Brushes.White } } };

2.
textblock.Inlines.Clear();
textblock.Inlines.Add(new Run("text"));
textblock.Inlines.Add(new Run("text") { Foreground = Brushes.White });