4

XAML:

<ScrollViewer x:Name="RtfEulaViewer" Grid.Row="1" VerticalAlignment="Top">
    <RichEditBox x:Name="RtfEula" IsHitTestVisible="False" IsFocusEngagementEnabled="False" IsReadOnly="True" 
         Background="{ThemeResource StandardBackground}" BorderThickness="0" TextWrapping="Wrap" />
</ScrollViewer>

Code:

StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
this.RtfEula.Document.LoadFromStream(TextSetOptions.FormatRtf, stream);

Absolute or relative HyperLinks in the RTF file that are click-able when it is opened by Word or WordPad, are just shown as normal text.

{\field{\*\fldinst HYPERLINK "http://www.microsoft.com"}{\fldrslt Microsoft}}

from the RTF specification is displayed in blue colour but is also inactive. The mouse pointer does not change if I move over it.

Is there a way to get active HyperLinks in some text box when loading an RTF file?

Jay Zuo
  • 15,653
  • 2
  • 25
  • 49
user3350539
  • 83
  • 1
  • 7
  • In your code, you've set `IsHitTestVisible="False"`. This will disable all input interaction. That's why your hyper link is not click-able. Removing this setting or changing its value to `True` should be able to solve your issue. – Jay Zuo Jun 04 '17 at 10:28
  • Wow, I set `IsHitTestVisible` to `True` and this solved it. Thank you @JayZuo. Please add it as answer, it fully solved the problem. I will mark it as answered. – user3350539 Jun 06 '17 at 07:43
  • Thank you, I've added it as an answer. Glad to know this helps you. – Jay Zuo Jun 06 '17 at 08:19

1 Answers1

4

In your code, you've set IsHitTestVisible="False". This will disable all input interaction. That's why your hyper link is not clickable. Removing this setting or changing its value to True should be able to solve your issue.

<RichEditBox x:Name="RtfEula" IsFocusEngagementEnabled="False" IsReadOnly="True" 
     Background="{ThemeResource StandardBackground}" BorderThickness="0" TextWrapping="Wrap" />
Jay Zuo
  • 15,653
  • 2
  • 25
  • 49