是否有可能在Silverlight中选择颜色标签? [英] Is it possible to seletively color a label in Silverlight?
问题描述
Blah blah bladity blah
我想要这个标签的前10%,这样字体颜色应该是红色的,其余的应该是绿色的。
这也许意味着它会为a和b的一部分着色。基本上像素的字体着色,而不是字符明智的。这是可能的,将如何完成?
是的,这将是这样的:
< Canvas>
< dataInput:Label Background =White>
< dataInput:Label.Foreground>
< LinearGradientBrush StartPoint =0,0.5EndPoint =1,0.5>
< GradientStop Color =RedOffset =0.1/>
< GradientStop Color =GreenOffset =0.1/>
< / LinearGradientBrush>
< / dataInput:Label.Foreground>
Blah blah bladity blah
< / dataInput:Label>
< / Canvas>
为了不 具有渐变效果,您需要同时设置 Offset
为相同的值。
$ b 注意:在这个字体大小没有任何变化)B和l是红色的,只有一小片a是。但是
Offset
中的0.1意味着10%,所以您可以减小字体大小或更改 Offset
值。 For instance, if I have a label:
Blah blah bladity blah
I want the first 10% of this label, such that the font color should be red, and the rest should be green.
This perhaps means it would color the Bl and PART of the a. Basically pixel-wise font coloring instead of character-wise. Is this possible and how would is be accomplished?
Yeah, it would be like this:
<Canvas>
<dataInput:Label Background="White" >
<dataInput:Label.Foreground>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Color="Red" Offset="0.1"/>
<GradientStop Color="Green" Offset="0.1"/>
</LinearGradientBrush>
</dataInput:Label.Foreground>
Blah blah bladity blah
</dataInput:Label>
</Canvas>
In order to not have the gradient effect, you need to set both Offset
to the same value.
Note: In this font size (standard, nothing changed) the "B" and "l" are red and only a small sliver of "a" is. But the "0.1" in Offset
means 10%, so you can either decrease font size or change the Offset
value.
这篇关于是否有可能在Silverlight中选择颜色标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!