我可以在WPF一个TextBlock的多种颜色? [英] Can I have multiple colors in a single TextBlock in WPF?

查看:188
本文介绍了我可以在WPF一个TextBlock的多种颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本块,上面写着一行文字:

I have a line of text in a textblock that reads:

检测到[动作]与[精度]的精确度

"Detected [gesture] with an accuracy of [accuracy]"

在WPF中,是否有可能对我来说,能够改变一个文本块中的元素的颜色吗?我能有一个文本块是多种颜色的?例如,我想整个TextBlock的是黑色的,除了手势的名字,我想是红色的。

In WPF, is it possible for me to be able to change the color of the elements within a textblock? Can I have a textblock be multiple colors? For example, I would like the whole TextBlock to be black except the gesture name, which I would like to be red.

在WPF这可能吗?

推荐答案

看看这有助于:

 <TextBlock>
      Detected
      <TextBlock Text="{Binding Gesture}" Foreground="Red" />
      with an accuracy of
      <TextBlock Text="{Binding Accuracy}" />
 </TextBlock>

这篇关于我可以在WPF一个TextBlock的多种颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆