【发布时间】:2020-10-14 00:56:15
【问题描述】:
我有一个 RTB,想通过超链接将鼠标光标更改为 MouseEnter 上的手。按下 Ctrl 时似乎默认为这个。我想要它只是当用户将鼠标悬停在超链接上时,无论 Ctrl 是否按下。
超链接当前从MouseLeftButtonDown 事件触发到网络浏览器,效果很好:
<RichTextBox.Resources>
<Style TargetType="Hyperlink">
<Setter Property="TextDecorations" Value="Underline"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Cursor" Value="Hand"/>
<EventSetter Event="MouseLeftButtonDown" Handler="Hyperlink_MouseLeftButtonDown" />
</Style>
</RichTextBox.Resources>
后面的代码:
private void Hyperlink_MouseLeftButtonDown(object sender, System.Windows.Input.MouseEventArgs e)
{
var hyperlink = (Hyperlink)sender;
Process.Start(hyperlink.NavigateUri.ToString());
}
事件按预期触发,它只是我想要的 MouseEnter 上的手形光标。我可以在同一个Style TargetType='Hyperlink'> 上进行两个单独的事件吗?
P.s RTB 格式设置为 Rtf。 谢谢
【问题讨论】:
标签: c# wpf hyperlink richtextbox