我正在尝试为具有x:Name =“ PART_rtb”的RichTextBox创建一些“自定义检查拼写”功能 必须在当前编辑的块上执行拼写检查。我正在尝试像这样检测该块
private void TextCheckTimer_Tick(object sender,EventArgs e)
{
foreach (var block in PART_rtb.Document.Blocks)
{
if (block.IsKeyboardFocusWithin)
block.Background = brushes.LightPink; // never run
}
}
但是此代码较新,即使您在RichTextBox对象中进行打印,也可以在其中找到带有KeyBoardFocus的任何块。有什么想法吗?