擦除 InkCanvas 的子级
我在窗口上有一个 InkCanvas
,允许用户使用手写笔、触摸或鼠标进行绘图。我还允许用户添加文本。用户点击“添加文本”按钮,然后点击画布上他们想要添加文本的位置。那里会出现一个文本框,允许他们输入。在进入或失去焦点时,我创建一个 ContentControl
并将其添加到 myInkCanvas.Children
。
我希望用户能够在 InkCanvas
处于擦除模式时擦除他们创建的文本(我正在使用 EraseByPoint
)。我尝试捕获内容控件的 MouseEnter
和 PreviewMouseMove
事件,但似乎都没有触发。
有我可以捕捉的事件吗?有没有更好的方法来处理这种情况?有可能吗?
I have an InkCanvas
on a window in which I allow the user to draw with a stylus, touch, or mouse. I also allow the user to add text. The user taps an "add text" button, then taps where on the canvas they would like their text. A textbox appears there, allowing them to type. On enter or lost focus I create a ContentControl
and add it to myInkCanvas.Children
.
I would like the user to be able to erase the text they have created when the InkCanvas
is in erase mode (I am using EraseByPoint
). I've attempted to capture the MouseEnter
and PreviewMouseMove
events of the content controls, but neither seem to fire.
Is there an event that I can capture? Is there a better way to handle this scenario? Is it even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用命中测试来实现此目的
看看这里
首先获取InkPresenter
,然后获取您的Point的HitTestResult
那么你可以使用
hitTestResult.VisualHit
删除这个对象You can use hit testing for this purpose
look at here
get InkPresenter first
then get HitTestResult of your Point
then you can use
hitTestResult.VisualHit
to remove this object