在TextBox中查找插入符号的位置

Ran*_*ngy 6 .net c# wpf

我需要知道插入符号在TextBox中的位置,这样我就可以弹出它附近的上下文菜单.如何找到它的位置(不是字符索引)?

Ran*_*ngy 8

发现这篇文章描述了如何做我需要做的事情.事实证明,你可以设置文本框的两个PlacementTarget 从GetRectFromCharacterIndex的PlacementRectangle,它会工作.