|
Hi,
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
e.g.
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)))); document.Blocks.Add(para); }
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;
para.Inlines.Add(hLink);
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?
Thanks!
|