WPF RichTextBox:在运行时用 UI 控件替换文本
我需要开发一个类似信使的文本框,其中某些标记将被 UI 控件替换。 例如,如果用户输入 :-)
,则应将其替换为笑脸图像。
我以前有过使用 WPF 的 RichTextBox
的经验,并且了解 TextPointer
和 TextContent
的概念。
我只是想知道:如何用 UI 控件替换 TextRange
?
I need to develop a messenger-like text box where certain tokens are being replaced with UI controls.
Just for example, if the user types :-)
, it should be replaced with a smiley image.
I have previous experience with WPF's RichTextBox
, and I understand the concept of TextPointer
and TextContent
.
I just want to know: how can I replace a TextRange
with a UI control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
刚刚知道怎么做:-)
享受!
Just figured out how to do it :-)
Enjoy!
这是另一个选项(语法格式化程序是我的,根据您的语法实现您自己的):
Here is another option (the syntax formatter is mine, implement your own according to your syntax):
抱歉,忘记了该方法的最后一部分::-)
...
...
玩得开心!,如果您有意见,请留下您的评论。
-吉利
Sorry, forgot the method's last section: :-)
...
...
Have fun!, leave your comments if you have ones.
-Gili