I seek advice for the best approach to implement a console-log viewer with WPF.
It should match the following criteria:
- fast scrolling with 100.000+ lines
- Some entries (like stacktraces) should be foldable
- long items wrap
- the list can be filtered by different criteria (searching, tags, etc)
- when at the end, it should keep scrolling when new items are added
- Line-elements can contain some sort of addition formatting like hyperlinks and occurrence counter
In general I have something in mind like the console window of FireBug and Chrome.
I played around with this but I didn't make much progress, because... - the datagrid can't handle different item heights - the scroll position is only updated after releasing the scrollbar (which is completely unacceptable).
I'm pretty sure, I need some form of virtualization and would love to follow the MVVM pattern.
Any help or pointers are welcome.
HighCore answer is perfect, but I guess it's missing this requirement:"when at the end, it should keep scrolling when new items are added".
According to this answer, you can do this:
In the main ScrollViewer (inside the DockPanel), add the event:
Cast the event source to do the auto scroll:
I should start selling these WPF samples instead of giving them out for free. =P
VirtualizingStackPanel
) which provides incredibly good performance (even with 200000+ items)DataTemplate
s for each kind ofLogEntry
type. These give you the ability to customize as much as you want. I only implemented 2 kinds of LogEntries (basic and nested), but you get the idea. You may subclassLogEntry
as much as you need. You may even support rich text or images.CollectionView
.WPF Rocks, just copy and paste my code in a
File -> New -> WPF Application
and see the results for yourself.Code Behind: (Notice that most of it is just boileplate to support the example (generate random entries)
Data Items:
PropertyChangedBase: