Sunday, January 29, 2012

Windows Phone, Silverlight and Rich Text Fields

I'm currently working with a mobile dating application, named as Hooxter. You should follow it on twitter @hooxter just in case You are interested how it develops, but now to the actual topic.

The mobile application has one screen where I need to display formatted text, basically it's a chat windows where the conversation is rolling and each post is displayed as own chapter together with the information who sent that post.

In QT this was pretty straight forward, since I can just use QTextBrowser to display it, but the story was different in Windows Phone application and specially when You use MVVM pattern.

If You have such problem, just combine the information from following three posts and You have the same functionality in WP.

First, take RichTextBox to use by using instructions in here.

Secondly You need to the content as bindable, simple solution from here.

Then last but not least, define the custom namespace by using the instructions from here.

Please also note that You need to add namespace for the new content You add to the model, check notes for that from this post