0

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.

enter image description here

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • seems very close to https://stackoverflow.com/q/18197263/103167 which also has no answers or even suggestions... except that one looks to have uniform height – Ben Voigt Jan 19 '18 at 21:08
  • TreeView with heavily edited TreeViewItem Template (to create columns) should be suitable. It can virtualize items and load them on demand (e.g. when expanding node), and with HeirarchicalDataTemplate you can still follow MVVM. – ASh Jan 20 '18 at 14:25
  • @Ash: But if each TreeViewItem has its own set of columns (perhaps inside a grid), then the columns won't be shared by items and won't stay uniform across items. Or am I missing something? – Ben Voigt Jan 20 '18 at 16:42
  • I think there are ways to make them uniform. Grid ColumnDefinitions can use SharedSizeGroup. or their Width can be bound to the same property. – ASh Jan 20 '18 at 20:15
  • @ASh: I think `SharedSizeGroup` is the thing I have been missing; will give it a try. – Ben Voigt Jan 21 '18 at 16:09

0 Answers0