WPF RichTextBox

By Michael Flanakin @ 6:27 AM :: 3737 Views :: .NET :: Digg it!

I just had to complain about the RichTextBox control in WPF. As part of the diff tool I'm working on, I spent a few hours working on an XSL stylesheet to color-code the different regions of the compared text files. Given the simplicity of XSL, I figured it'd be perfect to quickly get something out that looks the way I want it to and still leave room for customization later (i.e. to support VS Diff and/or TortoiseMerge styles later). So, off I go working on a stylesheet to format my proprietary XML (does anyone know of a standard XML representation of text changes?). Given my web experience, HTML was the easiest thing to go to, so that's what I did. Low and behold, HTML isn't supported by the WPF RTB. You've gotta be kidding me!? I guess this is just part of the "youth" of the technology.

While I have absolutely no doubt HTML support will be added later -- probably in the .NET 3.6/4.0 time frame -- I'm not waiting around for it. So, what are my options? One thread states that only text, RTF, XAML, and XAML package are supported; however, based on the test run right after HTML failed, RTF failed, too. I guess this leaves me with XAML, since text just won't cut it.

I wanted to learn XAML, so I guess I was just asking for it. The good news about this is that I should still be able to use my XSL approach and just have the stylesheet produce XAML instead of HTML. The other good thing about it is that the approach should enable me to get a little more fancy with the contents of the RTB. With some of the things I have in mind, this could be exactly what I need. It also gets me out of the RTF business, which is just one more "language"/API to learn.

As always, if anyone has any thoughts or suggestions, I'm all ears.

Ratings