2013-08-22 58 views
0

如何將使用導航的超鏈接放在Richtextbox中?現在,我有以下的,這讓我這個錯誤: 「XAMlParseException是未處理」在Richtextbox中使用導航進行超鏈接

XAML

<Page x:Class="SafeModeLiabilityAgreement" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="500" 
     Title="SafeModeLiabilityAgreement" FontFamily="Comic Sans MS"> 
    <Grid Background="White"> 


     <RichTextBox Margin="20,40,20,0" Name="RichTextBox1" VerticalAlignment="Top" Height="194" VerticalScrollBarVisibility="Auto" > 

      <FlowDocument> 

       <Paragraph> 
<LineBreak/> 

        <Hyperlink Foreground="Blue" NavigateUri="http://www.youtube.com/watch?v=rb3nY6avD8k" RequestNavigate="Hyperlink_RequestNavigate"> 
         How to manualy turn on/off safemode ? 
        </Hyperlink> 


       </Paragraph> 




      </FlowDocument> 

     </RichTextBox> 

    </Grid> 
</Page> 

VB.net

Public Class SafeModeLiabilityAgreement 
    Private Sub Hyperlink_RequestNavigate(ByVal sender As Object, ByVal e As RequestNavigateEventArgs) 
     Process.Start(New ProcessStartInfo(e.Uri.AbsoluteUri)) 
     e.Handled = True 
    End Sub 

End Class 
+0

看看內部的異常,並添加它,如果你仍然不知道該怎麼做。 –

+0

超鏈接應該在''我相信 – Julien

+0

我意識到我的xaml是錯誤的。我所要求的是我如何將一個超鏈接放在richtextbox中? –

回答

2

試着改變你的段落,這

<Paragraph> 
    <LineBreak/> 
     <TextBlock> 
     <Hyperlink Foreground="Blue" NavigateUri="http://www.youtube.co/watch?v=rb3nY6avD8k" RequestNavigate="Hyperlink_RequestNavigate"> 
         How to manualy turn on/off safemode ? 
     </Hyperlink> 
     </TextBlock> 

</Paragraph> 
+0

工作正常!我發誓我曾嘗試過。謝謝! –

+1

沒關係。我們一直在這裏互相幫助。 –