BArtWell
BArtWell

Reputation: 4044

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. I am using the LongListSelector and TextBlock for chat viewing. On Android I make formatting with HTML tags like a <img>, <a>, <b>, <i> and <u>. But TextBlock doesn't support HTML. How to make formatting and smiles on Windows Phone 8?

Upvotes: 0

Views: 190

Answers (1)

Sopuli
Sopuli

Reputation: 421

This works for Windows Phone Silverlight 7.5/8/8.1, but not for WinRT style WP8.1 apps.

<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. Most likely you need to make separate TextBlock for links which uses Tapevent to launch navigation.

Upvotes: 1

Related Questions