用于记录数据的WPF窗口,ObservableCollection,环形缓冲区 [英] WPF Window for Logging Data, ObservableCollection, ring-buffer

查看:108
本文介绍了用于记录数据的WPF窗口,ObservableCollection,环形缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们得到了基于MVVM模式的WPF应用程序.我们在滚动窗口中显示来自硬件的记录数据.
硬件将记录数据(只是字符串)连续写入ViewModel中的ObservableCollection中.
这很好. ObservableCollection的容量是有限的,例如到1000行.
一旦达到限制,我们就希望删除较旧的行并填写新的日志记录数据. (我们需要一个环形缓冲区)
我们尝试删除集合的前30%,然后将其余部分移到开头.但这不适用于这样的Collection.
我们还尝试使用有意义的Queue< string>.但是WPF窗口没有更新:绑定无效.
有什么主意吗?谢谢

SunnyApril

Hi,

we got a WPF application based on the MVVM pattern. We show the logging data comming from a piece of hardware in a scrolling window.
The logging data (just strings) are written by the hardware continously into an ObservableCollection in the ViewModel.
This works fine. The capacity of the ObservableCollection is limited, e.g. to 1000 lines.
As soon as the limit is reached we want to remove older lines and fill in new logging data. (We would need a ring-buffer)
We tried to remove the first 30% of the collection an move the rest down to the beginning. But this didn''t work with such a Collection.
We also tried to use a Queue<string>, which makes sense. But the WPF window did not update: Binding dosen''t work.
Got any idea? Thanks

SunnyApril

推荐答案

问题已解决:
http://bea.stollnitz.com/blog/?p=344 [
The problem has already been solved:
http://bea.stollnitz.com/blog/?p=344[^]


这篇关于用于记录数据的WPF窗口,ObservableCollection,环形缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆