如何在FlowDocument中启用超链接?

时间:2012-02-15 11:03:29

标签: wpf hyperlink flowdocument flowdocumentreader

我的数据库中有.htm文件,这些文件被转换为FlowDocument并放入FlowDocumentReader进行查看。 .htm文件里面有超链接:  1)内部(对文档的其他片段)  2)外部(通过文档名称到我数据库中的其他.htm文档)。 转换并放入FlowDocumentReader后,超链接为蓝色并带下划线,但点击它们时没有任何反应。 包含上述超链接的简化.htm代码如下:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="81.files/filelist.xml">
<title>Hadasd</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Template>Normal</o:Template>
  <o:LastAuthor>user</o:LastAuthor>
  <o:Revision>10</o:Revision>
  <o:TotalTime>118</o:TotalTime>
  <o:Created>2003-08-06T03:40:00Z</o:Created>
  <o:LastSaved>2006-11-03T10:34:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>20736</o:Words>
  <o:Characters>118199</o:Characters>
  <o:Company>NPC OGRT</o:Company>
  <o:Lines>984</o:Lines>
  <o:Paragraphs>277</o:Paragraphs>
  <o:CharactersWithSpaces>138658</o:CharactersWithSpaces>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:Zoom>90</w:Zoom>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
    {font-family:"MS Mincho";
    panose-1:2 2 6 9 4 2 5 8 3 4;
    mso-font-alt:"\FF2D\FF33 \660E\671D";
    mso-font-charset:128;
    mso-generic-font-family:roman;
    mso-font-format:other;
    mso-font-pitch:fixed;
    mso-font-signature:1 134676480 16 0 131072 0;}
@font-face
    {font-family:"\@MS Mincho";
    panose-1:0 0 0 0 0 0 0 0 0 0;
    mso-font-charset:128;
    mso-generic-font-family:roman;
    mso-font-format:other;
    mso-font-pitch:fixed;
    mso-font-signature:1 134676480 16 0 131072 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0cm;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:"Times New Roman";}
h1
    {mso-style-next:Обычный;
    margin-top:12.0pt;
    margin-right:0cm;
    margin-bottom:3.0pt;
    margin-left:0cm;
    mso-pagination:widow-orphan;
    page-break-after:avoid;
    mso-outline-level:1;
    font-size:16.0pt;
    font-family:Arial;
    mso-font-kerning:16.0pt;}
a:link, span.MsoHyperlink
    {color:blue;
    text-decoration:underline;
    text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
    {color:purple;
    text-decoration:underline;
    text-underline:single;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
    {margin:0cm;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:10.0pt;
    font-family:"Courier New";
    mso-fareast-font-family:"Times New Roman";}
@page Section1
    {size:595.3pt 841.9pt;
    margin:2.0cm 57.6pt 2.0cm 57.6pt;
    mso-header-margin:35.4pt;
    mso-footer-margin:35.4pt;
    mso-paper-source:0;}
div.Section1
    {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
    {
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-parent:"";
    mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
    mso-para-margin:0cm;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:10.0pt;
    font-family:"Times New Roman";
    mso-ansi-language:#0400;
    mso-fareast-language:#0400;
    mso-bidi-language:#0400;}
</style>
<![endif]-->
</head>

<body lang=RU link=blue vlink=purple style='tab-interval:35.4pt'>

<div class=Section1>



<p class=MsoPlainText style='text-align:justify'><span style='font-size:12.0pt;
font-family:Arial;mso-fareast-font-family:"MS Mincho"'><o:p>&nbsp;</o:p></span></p>


<p class=MsoPlainText style='text-align:justify;text-indent:27.0pt'><span
style='font-size:12.0pt;font-family:Arial;mso-fareast-font-family:"MS Mincho"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoPlainText style='text-align:justify;text-indent:27.0pt'><span
style='font-size:12.0pt;font-family:Arial;mso-fareast-font-family:"MS Mincho"'>dfasfdsafsdfasdfasdfasdfasdf<span style='mso-spacerun:yes'>  </span><o:p></o:p></span></p>

</div>

</body>

</html>

生成在FlowDocumentReader中的FlowDocument代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <Paragraph TextAlignment="center">
    <Span FontWeight="bold">
      <Run FontFamily="arial" FontSize="12.0pt">dasdasdasdas</Run>
    </Span>
  </Paragraph>
  <Paragraph Margin="26.95pt,2.0pt,0,0">
    <Run FontFamily="arial" FontSize="12.0pt"> </Run>
  </Paragraph>
  <Paragraph FontSize="16.0pt" FontFamily="arial" Margin="26.95pt,2.0pt,0,0">
    <Span FontWeight="normal" FontSize="12.0pt">

  <Paragraph TextAlignment="justify" TextIndent="27.0pt">
    <Span FontFamily="arial" FontSize="12.0pt">13 ноября 1998 года<Run>  </Run></Span>
  </Paragraph>
</FlowDocument>

为了“唤醒”FlowDocumentReader中的超链接,我该怎么办? 任何帮助表示赞赏!提前谢谢!