I'm trying to improve the real-time log display of a rather complicated system. Currently there is a significant tradeoff between situational awareness (improved by displaying only high-level events) and reproducibility (which requires lots and lots of details). The obvious approach is to structure the details as a tree and allow their display to be expanded and collapsed.
The existing implementation uses just a RichTextbox. I'd like to use MVVM for my rewrite, not only because it's a best practice but also to enable behavior such as "Show details of an operation while it is ongoing, then automatically collapse them once it has successfully completed.".
As a further complication, the log records have some structure, which needs to be displayed in a columnar format. The nesting should be accomplished using the description column only (can be through pure indentation, as depicted, or using tree lines).
Can you recommend a way to map this data structure onto WPF template elements? There doesn't seem to be a way to produce a sequence of DataGridRow
objects from a parent object. And because the rows do not have uniform height (some of the detail data is multiline), trying to use a WPF tree for the description and then synchronize the vertical placement of data in other columns doesn't seem feasible.
Will I have to give up on the idea of a data-bound model, and use more of a view-controller design with manual creation of WPF elements, with references to these elements such as DataGridRow
stored explicitly within the in-memory tree structure, and implement collapsing and expanding by iterating through the child items and updating each descendant's Height property of the associated WPF element object?
And if I do break the data/presentation wall and use imperative coding style, is there something similar to WinForms SuspendLayout
/ResumeLayout
that I can use to achieve just a single layout pass per collapse, no matter how many rows changed in height?
Here is a quick mockup of the tree structure made using WPF+XAML. It's just a Grid without any document structure -- all the text elements are direct children of the Grid with manually set Grid.Row
and Grid.Column
attached properties. Clearly that would not be suitable for an implementation with new data and structure being generated in real time.