views:

72

answers:

0

I have an app that is similar to a chat application. It also creates hyperlinks in many situations, which are added to the inlines of a TextBlock.

The problem is, once I reach a few dozen hyperlinks, the mouseovers become horribly slow! It takes several seconds to change colour, and CPU usage shoots to 100%.

I tested this out with a very simple app that does the following:

        Span s = new Span();

        for (int i = 0; i < 1000; i++)
        {
            Hyperlink h = new Hyperlink(new Run("sample text "+i));
            s.Inlines.Add(h);
            s.Inlines.Add(new Run(System.Environment.NewLine));
        }
        TextBlock t = new TextBlock();
        t.Inlines.Add(s);
        main.Children.Add(t);

The result was the same. Many hyperlinks become really slow. Is there any way to make them faster? I have tried stackpanel virtualization, but it doesn't solve the issue.