【发布时间】:2017-12-07 13:30:44
【问题描述】:
我在使用 powershell 和设置 TextBlock 中文本的一部分时遇到问题。
我使用一个函数将文本推送到运行空间窗口和其中的 TextBlock,效果很好。
Function Update-Log {
Param (
$Content,
$type = "Black"
)
$syncHash.Window.Dispatcher.invoke(
[action]{$syncHash.log_txt.Foreground = $type; $syncHash.log_txt.Inlines.Add($Content); },
"Normal"
)
}
即使是颜色的变化也没有问题。但现在我想标记单个单词bold。我尝试了一种务实的方法:
Update-Log "Here is some <bold>bold</bold> text."
不幸的是,这不起作用。你能帮我找到解决这个问题的方法吗?
【问题讨论】:
标签: powershell textblock runspace