Custom RTF TextBlock for WPF

I was working on a project where my customers wanted to customize the welcome text of the application, and I was thinking I go for the WebBrowser with html source or handmade parsing of something in some kind of rich format?

HTML was little to complex for beginners and too easy to make a mess (which I would have been asked to debug).

I came up with my own rich format very similar to WordPress shortcodes

Here’s my first version of it:

Font weight:
[weight=value] – Start tag accepting string values (check MSDN for accepted values):
[weight] – End tag

Font size:
[fsize=value] – Start tag accepting a double value:
[fsize] – End tag

[color=value] – Start tag accepting string values (HEX,KnownColor ecc, everything that this method can convert to a Color: ‘ColorConverter.ConvertFromString‘)
[color] – End tag

[image=value] – Start tag accepting string values (Path to image file supported by WPF)
[image] – End tag

Many others coming in future versions.

Don’t pay attention to my parsing solution 😉

Check the source on GitHub


Leave a Reply

Your email address will not be published. Required fields are marked *