private void SubscribeToAllHyperlinks(FlowDocument flowDocument)
 {
     foreach (Hyperlink hyperlink in HtmlToFlowDocumentConverter.GetVisuals((DependencyObject)flowDocument).OfType <Hyperlink>())
     {
         hyperlink.RequestNavigate += new RequestNavigateEventHandler(this.link_RequestNavigate);
     }
 }
        private static IEnumerable <DependencyObject> GetVisuals(DependencyObject root)
        {
            foreach (DependencyObject dependencyObject in LogicalTreeHelper.GetChildren(root).OfType <DependencyObject>())
            {
                DependencyObject child = dependencyObject;
                yield return(child);

                foreach (DependencyObject visual in HtmlToFlowDocumentConverter.GetVisuals(child))
                {
                    yield return(visual);
                }
                child = (DependencyObject)null;
            }
        }