Hon*_*ina 2 c# string wpf colors code-behind
我需要在后面的代码中更改颜色为文本字符串的一部分..
我的exaple:
textblock1.Text = string1 + string2 + string3;
Run Code Online (Sandbox Code Playgroud)
字符串有动态值,我希望在以蓝色运行程序后显示string2,并且必须在后面的代码中定义.
这是可能的?谢谢!
小智 5
我希望这会帮助你:
<TextBlock FontSize="16">
<Run Foreground="Red">Your_Text_1</Run>
<Run Foreground="Orange">Your_Text_2</Run>
<Run Foreground="purple">Your_Text_3</Run>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
那工作
textblock1.Inlines.Clear();
textblock1.Inlines.Add(new Run(string1));
textblock1.Inlines.Add(new Run(string2) { Foreground = Brushes.Blue });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8956 次 |
| 最近记录: |