在文本框中查找插入符号的位置
问题描述:
我需要知道插入符在TextBox中的位置,以便可以在其附近弹出一个上下文菜单.如何找到它的位置(不是字符索引)?
I need to know the position of the caret in a TextBox so I can pop up a context menu near it. How do I find its placement (not character index)?
答
找到本文描述如何做我需要做的事情.事实证明,您可以同时从GetRectFromCharacterIndex设置文本框和的PlacementTarget,并且可以使用.
Found this article describing how to do what I need done. Turns out you can set both the PlacementTarget of the textbox and the PlacementRectangle from GetRectFromCharacterIndex and it will work.