怎么得到RichTextBox中的光标位置
就是 文本框 中一闪一闪的那个 竖线条
[解决办法]
请参考代码:
Point a = new Point();
bool idle;
private void richTextBox1_ContentChanged(object sender, ContentChangedEventArgs e)
{
if (idle)
{
string newText = proc.ParseXAML(richTextBox1.Xaml);
richTextBox1.Xaml = proc.ProcessText(newText);
idle = false;
}
}
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
var rect = richTextBox1.Selection.Start.GetCharacterRect(LogicalDirection.Backward);
a = new Point(rect.X, rect.Y);
idle = true;
}
private void richTextBox1_KeyUp(object sender, KeyEventArgs e)
{
var newPos = richTextBox1.GetPositionFromPoint(a).GetNextInsertionPosition(LogicalDirection.Forward);
richTextBox1.Selection.Select(newPos, newPos);
}