你可以使用richtextbox selectionchanged来查找双击事件吗?
本文关键字:双击 事件 查找 可以使 richtextbox selectionchanged | 更新日期: 2023-09-27 18:12:48
我试图找到一种方法来获得一个richtextbox的选定文本一旦一个词被双击。richtextbox的设置如下:
<RichTextBox x:Name="rtbStoryLine" Grid.Column="1" Grid.Row="3" Grid.RowSpan="4" Margin="0,15,16,17" FontFamily="Arial" FontSize="25" IsReadOnly="True" MaxWidth="700" MaxHeight="130" ToolTipService.ToolTip="This box displays the selected line below." SelectionChanged="rtbStoryLine_SelectionChanged" />
我在后面的代码中添加文本,如:
public void AddTextt(string text2Add)
{
Paragraph p = new Paragraph();
Run r = new Run();
r.Text = text2Add;
p.Inlines.Add(r);
rtbStoryLine.Blocks.Clear();
rtbStoryLine.Blocks.Add(p);
}
在选择更改中,我想检查是否有双击,然后对突出显示的单词做一些操作。
我建议使用鼠标DoubleClick
事件,然后将选择与存储在某个变量中的前一个进行比较。这似乎比试图从SelectionChanged
中检测DoubleClick
事件更合理。祝好,AB