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>
代码:
StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
this.RtfEula.Document.LoadFromStream(TextSetOptions.FormatRtf, stream);
RTF 文件中的绝对或相对超链接在用 Word 或写字板打开时可点击,仅显示为普通文本。
{\field{\*\fldinst HYPERLINK "http://www.microsoft.com"}{\fldrslt Microsoft}}
来自 RTF 规范,以蓝色显示,但也处于非事件状态。如果我移动到它上面,鼠标指针不会改变。
有没有办法在加载 RTF 文件时在某些文本框中获取事件的超链接?
最佳答案
在您的代码中,您设置了 IsHitTestVisible="False"
。这将禁用所有输入交互。这就是为什么您的超链接不可点击的原因。删除此设置或将其值更改为 True
应该能够解决您的问题。
<RichEditBox x:Name="RtfEula" IsFocusEngagementEnabled="False" IsReadOnly="True"
Background="{ThemeResource StandardBackground}" BorderThickness="0" TextWrapping="Wrap" />
关于c# - UWP RichEditBox : How to enable HyperLinks for loaded RTF files (Document. LoadFromStream),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44280937/