UWP RichEditBox: how to enable HyperLinks for loaded RTF files (Document.LoadFromStream)
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 an RTF file that are clickable when Word or WordPad is opened are displayed as plain text only.
{\field{\*\fldinst HYPERLINK "http://www.microsoft.com"}{\fldrslt Microsoft}}
from the RTF BOM is displayed in blue, but is also inactive. The mouse pointer does not change if I move over it.
Is there a way to activate HyperLinks in some textbox when loading RTF file?
+3
source to share
1 answer
In your code, you have installed IsHitTestVisible="False"
. This will disable all input interactions. This is why your hyperlink is not available. Removing this setting or changing its value True
should not solve your problem.
<RichEditBox x:Name="RtfEula" IsFocusEngagementEnabled="False" IsReadOnly="True"
Background="{ThemeResource StandardBackground}" BorderThickness="0" TextWrapping="Wrap" />
+3
source to share