views:

319

answers:

2

I have text I am displaying in SIlverlight that is coming from a CMS that is used to store web content. There are fields in the cms like name and description that contain html tags and encoded characters.

What is the best way to convert/strip these from the text so they can be displayed in a silverlight textblock

I am leaning towards regex but I was wondering if there was a decoding class somewhere in the SL runtime that I could use to decode/convert (=>) things like this:

&#8212 => --

&#8217 => '

  => space

<p> => cr/lf

</p> => cr/lf cr/lf

<br/> =>cr/lf
A: 

What you are trying to accomplish requires a control that understands how to render "rich text" like HTML etc. Since (As far as I know) Silverlight 2 & 3 does not include a suitable control at this time, I have been using a free custom textblock control for my RSS , XML and HTML needs.

There are seeral good ones out there, and easy to implement. One example can be found here

http://blogs.msdn.com/delay/archive/2008/06/11/again-with-the-support-for-simple-html-display-in-silverlight-htmltextblock-sample-updated-for-silverlight-2-beta-2.aspx

PortageMonkey
A: 

I ended up doing several stringbuilder.replace's to clean up the html that I didn't need/want in the SL display string. Simple but it met my needs.

MIantosca