3
XAML:UWP RichEditBox:如何启用加载RTF文件链接(Document.LoadFromStream)
<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>
代码:RTF文件
StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
this.RtfEula.Document.LoadFromStream(TextSetOptions.FormatRtf, stream);
绝对或相对超链接的点击能当它由Word或写字板打开时,只显示为普通文本。
{\field{\*\fldinst HYPERLINK "http://www.microsoft.com"}{\fldrslt Microsoft}}
来自RTF规范以蓝色显示,但也是不活动的。如果我移动它,鼠标指针不会改变。
加载RTF文件时,是否有一种方法可以在某些文本框中获得活动的HyperLink?
在你的代码中,你已经设置了'IsHitTestVisible =“False”'。这将禁用所有输入交互。这就是为什么你的超链接不能点击的原因。删除此设置或将其值更改为“True”应该能够解决您的问题。 –
哇,我把'IsHitTestVisible'设置为'True',这解决了它。谢谢@JayZuo。请添加它作为答案,它完全解决了这个问题。我会将其标记为已回答。 – user3350539
谢谢,我已将它添加为答案。很高兴知道这可以帮助你。 –