[英]How to apply simple formatting to text in TextBlock?
In my application I need to view chat with smiles and simple formatting (bold, italic, underline and links) by parsing BB codes in message text. 在我的应用程序中,我需要通过解析消息文本中的BB代码来查看带有微笑和简单格式(粗体,斜体,下划线和链接)的聊天。 I am using the LongListSelector and TextBlock for chat viewing. 我正在使用LongListSelector和TextBlock进行聊天查看。 On Android I make formatting with HTML tags like a <img>
, <a>
, <b>
, <i>
and <u>
. 在Android上,我使用HTML标签(例如<img>
, <a>
, <b>
, <i>
和<u>
进行格式化。 But TextBlock doesn't support HTML. 但是TextBlock不支持HTML。 How to make formatting and smiles on Windows Phone 8? 如何在Windows Phone 8上进行格式化和微笑?
This works for Windows Phone Silverlight 7.5/8/8.1, but not for WinRT style WP8.1 apps. 这适用于Windows Phone Silverlight 7.5 / 8 / 8.1,但不适用于WinRT样式WP8.1应用程序。
<TextBlock FontFamily="Verdana" Foreground="White">
<Run Text="Bold " FontWeight="Bold"/>
<Run Text="Italic " FontStyle="Italic"/>
<Run Text="Underline " TextDecorations="Underline"/>
</TextBlock>
Displaying image and hyperlink is more complex. 显示图像和超链接更为复杂。 You can't (to my knowledge) insert image or use events inside TextBlock
. (据我所知)您不能在TextBlock
内插入图像或使用事件。 Most likely you need to make separate TextBlock
for links which uses Tap
event to launch navigation. 最有可能需要为使用Tap
事件启动导航的链接创建单独的TextBlock
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.