WPF RichTextBox:如何使用绑定连续更新 [英] WPF RichTextBox : How to update continuously using binding
问题描述
我想在RichTextBox控件中显示已删除的文本数据以及Date&时间戳记.该数据被连续添加.我可以使用richTextBox.AppendText方法将此数据添加到richtextbox中,但我想使用数据绑定来完成.
I want to display the recevied text data in a RichTextBox control along with Date & Time Stamp. This data is getting appended continously. I can add this data in the richtextbox with the richTextBox.AppendText method but i want to do it using data binding.
我如何使用数据绑定来做到这一点?反正会影响应用程序性能吗?
How i can do this using Data Binding? And will it affect the application performance anyway?
预先感谢
IamHum
推荐答案
您需要使用附加属性才能访问文件"属性,或覆盖控件并添加依赖项属性.根据设计,文档"不是依赖项属性,这就是为什么您不能绑定到它.
You'd need to use an attached property to get to the "Document" property, or override the control and add a dependency property. By design "Document" is not a dependency property, that's why you can't bind to it.
这不是dp,因为创建RichTextBox的目的是保留大量文本-因此,始终不停地处理文本可能会很麻烦.可以说,我需要将它与MVVM一起使用,并且它没有任何问题 性能.
It's not a dp because RichTextBox was created to keep large amounts of text - so it would probably be quite a strain to juggle with the text inside around, all the time. Suffices to say, I needed to use it with MVVM and haven't had any problems with its performance.
这篇关于WPF RichTextBox:如何使用绑定连续更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!