wp7中相同字符串的多种颜色 [英] Multiple color for same string in wp7

查看:67
本文介绍了wp7中相同字符串的多种颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,

我是Windows手机开发的初学者。

我已将字符串定义如下

Hello All,
I am beginner to Windows phone Development .
I have defined string as below

string str = "[Basic settings:] bla bla bla"+
             "[Delete Settings:] bla bla bla"+
             "[Update Settings:] bla bla bla";
//this is a long string in same formate

< br $>




< TextBlock Name =txtInfotext ={Binding str}Foreground =Yellow >



这很好用。文本块中的所有文字都显示黄色彩色文字。

我的问题:是否可以在方括号括起的红色中显示文本?保留为黄色。

来自上面示例:[基本设置:],[删除设置:],[更新设置:]红色

和所有bla,bla, bla是黄色的吗?



提前谢谢!




<TextBlock Name="txtInfo" text="{Binding str}" Foreground="Yellow">

This works fine.All text in a textblock display "Yellow" colored text.
My Question :Is it possible to display a Text in "Red" which is surrounded by square brackets? and remaining in Yellow.
From above Example : [Basic settings:],[Delete Settings:],[Update Settings:] in Red
and all bla, bla ,bla are in Yellow ?

Thanks in advance!

推荐答案

不是同一个字符串。字符串没有颜色。 :-)



但是使用Web应用程序,解决方法太简单了。最好的解决方法是使用某些样式标记来打破这一行,例如< span class =First> ...< / span> < span class =second> ...< / span> ,类似的东西。



-SA
Not for the same string. Strings do not have colors. :-)

But with a Web application, a work around is way too simple. The nicest work around would be to break the line with some style tags, such as <span class="First">...</span>, <span class="second">...</span>, something like that.

—SA


解决了我自己!





使用Run和textBox.Inline.Add()
Solved Myself!


Using Run and textBox.Inline.Add()


这篇关于wp7中相同字符串的多种颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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