【发布时间】:2013-08-23 13:15:34
【问题描述】:
如何在 Richtextbox 中放置带导航的超链接?现在我有以下内容,它给了我这个错误:“XAMlParseException was unhandled”
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
【问题讨论】:
-
看一下内部异常,如果还是不知道怎么办就加上。
-
超链接应该在
<Run>我相信 -
我意识到我的 xaml 是错误的。我要问的是如何在富文本框中放置超链接?
-
内部错误:“无法将'System.Windows.Documents.Hyperlink'类型的对象转换为'System.Windows.Controls.TextBlock'”
标签: wpf vb.net hyperlink richtextbox