This project has moved. For the latest updates, please go here.


May 3, 2012 at 1:52 AM


I am using the WPF Extended Toolkit RichTextBox. It is part of a DataTemplate inside a ListView.

I am binding the Text property to some text property of the items and it is showing fine.

I created a custom ITextFormatter that reads the text and builds a XML FlowDocument


foreach (var line in text.Split('\n'))
//some manipulations
Paragraph para = new Paragraph();    para.Inlines.Add(new Run(manipulatedText1));
 para.Inlines.Add(new Hyperlink(new Bold(new Run(manipulatedText2))));

Now I want to be able to do something when a link is clicked. I am using MVVM (with Catel) and I would prefer to follow this pattern - that is - run a command from/in a VM.

I tried to add a DP to the ITextFormatter implementation and then set the Hyperlink.Command:

var hLink = new Hyperlink(new Bold(new Run(line.Substring(match.Index, match.Length))));
hLink.TargetName = match.Value;
hLink.Command = HyperlinkCommand;

but this does not work (I am not able to pass the command form VM properly)

I also tried to do a test and define the command with the ITextFormatter but this didn't work as well.

Any suggestions? Implementation? Am I on the right path or maybe I should do something completely different?