Reputation: 797
When using chat app like WhatsApp text can be made bold, italics, underline among other text formatting features.
For instance:
This is a boy who can sing very well if you only allow him to do so.
Even stack overflow uses this text formatting feature i.e ** etc instead of the web based one of html tags. I would like to implement it on my app so that i dont use web browser control to do the job because the web browser on windows phone has many set backs compared to the one windows phone. I have been thinking of making a custom control for this purpose but i have no idea on how to go about it.
Upvotes: 2
Views: 176
Reputation: 4490
Check out my implementation of RichTextBlock
that accept Html and builds the text from it. The idea is in supplying attached property, that on change (this property) event will build the internal structure of RichTextBlock
from supplied in this property html (via parsing html and translating it into RichTextBlock
blocks).
Upvotes: 1
Reputation: 14044
This could be done in a TextBlock
<TextBlock Margin="10" TextWrapping="Wrap">
This is a <Bold>boy</Bold> who can <Italic>sing very well</Italic> if you only <Bold><Italic>allow</Bold></Italic> him to do so.
</TextBlock>
For Underline just use <Underline>Your Underlined Text</Underline>
You can have a look on The TextBlock control - Inline formatting It not only covers Bold Italic Underline but also LineBreak, Hyperlink, Span and formatting from C#/Code-Behind. A lot of samples which inturns make your TextBlock Control to do all set of HTML formatting for the Text
Upvotes: 2