This project is read-only.

Changing hyperlink color in HtmlTextBlock without paragraph

Oct 22, 2014 at 8:04 AM
Hi, it's possible change the hyperlink color in HtmlTextBlock without paragraph?
Now I use this:
private void OnHtmlTextBlockLoaded(object sender, RoutedEventArgs e)
{
    var block = (HtmlTextBlock)sender;
    block.Generators["a"] = new ParagraphGenerator
    {
        FontSize = 15,
        FontWeight = FontWeights.Bold,
        Foreground = new SolidColorBrush(Colors.Red)
    };
}
Note: development app for Windows Phone 8.1
Oct 22, 2014 at 8:44 AM
Try this
var linkGenerator = block.Generators["a"] as LinkGenerator;
if (linkGenerator != null)
    linkGenerator.Foreground = new SolidColorBrush(Colors.Red);
Marked as answer by a78life on 10/22/2014 at 11:37 PM
Oct 23, 2014 at 7:39 AM
Thanks rsuter! Great job!
Oct 23, 2014 at 7:41 AM
You're welcome.. If you like the project, please review and follow it..
Oct 24, 2014 at 8:55 AM
Question: why not always links are red but are blue without style color?
Oct 24, 2014 at 9:08 AM
Sorry, whats your question? Do you want that links are by default red (when using the library as is)?
Oct 24, 2014 at 9:26 AM
That's right, i wish it were always red links but this is not the case
Oct 24, 2014 at 9:36 AM
Edited Dec 16, 2014 at 8:11 AM
The default color for links is blue (almost in all browsers). What exactly is your request? You dont want to run the code above on every HtmlTextBlock instance in your project?
Dec 16, 2014 at 8:12 AM
Do you want the link color to be the accent color?