How to modify Hyperlinks

2 posts, 0 answers
  1. F
    F avatar
    1 posts
    Member since:
    Nov 2014

    Posted 24 Nov 2014 Link to this post

    Hi. I'm trying to figure out how to locate modify the attributes of a Hyperlink (e.g. NavigateUri) after it's been created. What's puzzling me is that it seems that you can create a HyperlinkInfo object and then insert it into the document, but there doesn't seem to be any way to get a HyperlinkInfo object back from the document. When I import my document from RTF and then save as xaml, I got the following results (at bottom.)

    I know that there are ways to pull back start tags, inlines, and so forth, but none of those seem to correspond to an actual HyperlinkInfo object. Furthermore, I'm seeing two different kinds of Hyperlink information (one in the <FieldRangeStart...>xxxx</FieldRangeStart...> pair, and another in the <HyperlinkRangeStart...>xxxx</HyperlinkRangeStart> pair. It's not clear where I should make mods.

    Also: In your InsertHyperlink demo, if I insert a Hyperlink and then come back to edit it, then in module InsertHyperlinkDialog.xaml.cs, the ShowDialog procedure on line 74 includes a parameter for "CurrentHyperLinkInfo as HyperlinkInfo". Indeed, if I break at that point, the information is there, having apparently been supplied by the editor. However, I cannot figure out how to get the same info independent of the editor.

    Please explain how this all works. The xaml snippet I promised is as follows:

    <t:FieldRangeStart AnnotationID="558">
           <t:HyperlinkField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" LocationInFile="" NavigateUri="hypercase:///cite_000031"
    NumericFormatting="" Target="" />
    <t:HyperlinkRangeStart AnnotationID="559">
        <t:HyperlinkInfo NavigateUri="hypercase:///cite_000031" />
        <t:Span FontSize="16" FontStyle="Italic" StyleName="Hyperlink" Text="Ass’n of Am. Physicians and Surgeons Inc. v. Clinton" />
        <t:Span FontSize="16" StyleName="Hyperlink" Text=", 997 F.2d 898, 909 (D.C. Cir. 1993)" />
    <t:HyperlinkRangeEnd AnnotationID="559" />
    <t:FieldRangeEnd AnnotationID="558" />


  2. Tanya
    Tanya avatar
    377 posts

    Posted 27 Nov 2014 Link to this post


    Usually inserting a hyperlink in RadRichTextBox creates it as a HyperlinkRangeStart – HyperlinkRangeEnd pairs. You can see the example below to figure out how to get the HyperlinkInfo of the clicked hyperlink in this case: 
    var clickedLink = this.radRichTextBox.Document
    string uri = clickedLink.HyperlinkInfo.NavigateUri;
    clickedLink.HyperlinkInfo.NavigateUri = "SomeURI";

    Occasionally, importing a document would produce a HyperlinkField, which is an object corresponding to hyperlink fields in the Office OpenXml specification. In those cases you can follow the next snippet:
    var start = this.radRichTextBox.Document
        .Where(x => x.Field is HyperlinkField)
    if (start != null)
        (start.Field as HyperlinkField).NavigateUri = "SomeURI";

    On a side note, the XAML you are getting as a result is very strange and we haven’t encountered such setup before. If you want you can send us the RTF file you are importing, so we can inspect it in details.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top