Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient live log-viewer in WPF

Tags:

wpf

I would like an efficient log-viewer control in WPF that simply shows a live log as messages are being added. It is no problem to hook up to notifications from the log-system, but I am worrying that a log window will come to a crawl with each appending log-line once the number of log-lines grow large.

The log notification events will simply provide a log string (along with some meta) that I want to append to the lines in a TextBox or similar with a scroll bar. Assuming plenty of memory, appending a large number of lines should not be a memory problem, but I would not like the system slowing down once line number 10,000 is being added.

I assume that binding a TextBox to a simple string dependency property will get rather slow once the string is getting into MB size and thousands of lines.

How could I write such a control efficiently in WPF?

like image 878
Holstebroe Avatar asked May 13 '11 08:05

Holstebroe


1 Answers

why not use a listbox? create a collection where you add your log message every time and just bind this collection to your itemscontrol itemssource.

EDIT: i use a datagrid in my projects to show messages coming from WCF service

EDIT2: some Itemsscontrols have the following property which should help:

<ListBox VirtualizingStackPanel.IsVirtualizing="True" />
like image 199
blindmeis Avatar answered Oct 22 '22 16:10

blindmeis