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?
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With