如何在Silverlight4的RichTextBox中的超链接中创建RelativeURL? [英] How do I make a RelativeURL in a Hyperlink from a RichTextBox in Silverlight4?
问题描述
使超链接引用relativeURI的最简单方法是什么?
我有以下代码,但是它需要完整的URI,因此它无法按我的意愿运行(但根据MSDN上的规范运行).
Hi,
What is the easiest way to make a hyperlink reference a relativeURI?
I''ve got the following code, but it expects a full URI so it doesn''t work as I would like it (but works according to the specification on MSDN).
<RichTextBox IsReadOnly="True">
<Paragraph>
<Run>Please </Run>
<Hyperlink
NavigateUri="/Books/Chapters/Page"
TargetName="ContentFrame">
click here
</Hyperlink>
<Run> to see more</Run>
</Paragraph>
</RichTextBox>
我看了几篇文章:
Creating-Actionlinks-in-a-Silverlight-RichTextBox
[ ^ ]
Using-RichTextBox-in-Silverlight-4 [
I''ve had a look at a few articles:
Creating-Actionlinks-in-a-Silverlight-RichTextBox
[^]
Using-RichTextBox-in-Silverlight-4[^]
but just wondered if anyone had a simple trick to do this.
Best regards
Erik
推荐答案
好吧,我知道我并未将所有工作都投入解决方案中.看到此答案... 在服务器上运行的href标记错误 [^ ]
Okay I knew I didn''t put all that work into a solution for nothing. See this answer...href tag error running on server[^]
我没有设法使其正常工作,所以我只是采用了快速而肮脏的解决方法:
I didn''t manage to get this to work properly, so instead I just went with the quick and dirty workaround:
<richtextbox isreadonly="True">
<paragraph>
<run>Please </run>
<hyperlink click="Hyperlink_Click"> click here </hyperlink>
<run> to see more</run>
</paragraph>
</richtextbox>
然后在HyperLink_Click事件中导航
And then navigate in the HyperLink_Click event
private void Hyperlink_Click(object sender, RoutedEventArgs e)
{
TargetName="ContentFrame"
var uri = new Uri("/Chapters/Pages", UriKind.Relative);
NavigationService.Navigate(uri);
}
这篇关于如何在Silverlight4的RichTextBox中的超链接中创建RelativeURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!