Changing hyperlink color in HtmlTextBlock

Jul 2, 2012 at 7:08 PM
Edited Jul 2, 2012 at 7:08 PM

Is it possible to change the color of hyperlinks generated in the HtmlTextBlock control? The "Foreground" property doesn't seem to apply to the hyperlink.

Jul 2, 2012 at 8:14 PM

I just added support for the Foreground and Background property (check out with subversion, not in NuGet yet)... If you want to change the color of the hyperlinks to another color then the rest of the text, overload LinkGenerator and replace the original with an overloaded instance:


    public class MyLinkGenerator : LinkGenerator
        protected override Action CreateLinkAction(Hyperlink hyperlink, string link, IHtmlTextBlock textBlock)
            hyperlink.Foreground = new SolidColorBrush(Colors.Blue);
            return base.CreateLinkAction(hyperlink, link, textBlock);



htmlPresenter.Generators["a"] = new MyLinkGenerator();

Jul 2, 2012 at 8:15 PM


Jul 2, 2012 at 8:21 PM

Tell me if its working for you..

Jul 2, 2012 at 9:15 PM

It works perfectly!