在Richtextbox中使用导航的超链接 [英] Hyperlink with Navigation in a Richtextbox

查看:125
本文介绍了在Richtextbox中使用导航的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Richtextbox中添加带导航的超链接?现在我有以下内容,它给了我这个错误:XAMlParseException未处理

How would I put a hyperlink with Navigation in a Richtextbox? Right now I have the following and it gives me this error: "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


推荐答案

尝试将您的段落更改为此

try changing your paragraph to this

<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>

这篇关于在Richtextbox中使用导航的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆