我有一个来自 Xtended WPF Toolkit 的 Rich-Text-Box 来显示绑定到一些 .rtf 文件的文本。我想要“只读”框,但同时我希望文件中的超链接处于活动状态并且可供用户点击。为了实现这一点,我创建了这样的框:<xctk:RichTextBox x:Name="richTextBox" Cursor="Arrow" VerticalAlignment="Stretch" Text="{Binding text}" Focusable="False" IsDocumentEnabled="True"> <xctk:RichTextBox.Resources> <Style TargetType="Hyperlink"> <Setter Property="Cursor" Value="Arrow" /> <EventSetter Event="PreviewMouseLeftButtonDown" Handler="Hyperlink_MouseLeftButtonDown"/> </Style></xctk:RichTextBox.Resources></xctk:RichTextBox>几乎一切正常,我可以单击富文本框中的链接,但是当鼠标悬停在链接上时,光标会变成“文本选择”光标(就像您将鼠标悬停在文本输入字段上一样在这里),这看起来很愚蠢。所以看起来这条线<Setter Property="Cursor" Value="Arrow" />正在被忽视。有没有什么办法解决这一问题?
2 回答
斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
尝试向将属性设置为的IsMouseOver触发器添加:StyleIsEnabledfalse
<Style TargetType="Hyperlink">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="Hyperlink_MouseLeftButtonDown"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
- 2 回答
- 0 关注
- 362 浏览
添加回答
举报
0/150
提交
取消