Recursive XAML view?

  • Okay, here's the deal - still working on my project which is actually nearing completion (will the wonders ever cease?)

    However, I still need to implement a reporting page where a pupil's grades are displayed according to the categories they were applied to. The categories are hierarchical and tree-like: There's the final grade which results from the two semesters' grades which in turn both result from exams and oral grades, the latter of which in turn result from grades for participation, tests and homework.

    Basically, this:

    final grade
      |- Semester 1
          |- Exams
          |- Oral grades
              |- Tests
              |- Homework
              |- Participation
      |- Semester 2

    One example of the hierarchy - there are also final grades after just one semester, which I want to look like this in the final view:

    Only the leafs have actual grades assigned to them, but I'd also like the ability to override the calculations. Doing so is not a big problem - but which method am I to choose when trying to display this in a Windows 10 UWP project using XAML?

    I'm asking because someone might have come across something like that before and might be willing to spare me from haring off in unsuitable directions :)

  • I'm not clear on what the exact question is, but I think what you want is an ItemTemplateSelector(or is it DataTemplateSelector). You can then check the type of the ViewModel being bound against, then select a control style based on either just the type or type + other conditions.

  • Doesn't solve the hierarchy problem which is dynamic - could have two levels, three, four or even more.

  • That's part of my confusion. What exactly is the problem?

    Sounds like a ListBoxItem possibly containing a ListBox whom's ListBoxItems may also contain ListBoxes.

  • This thing you have could either be some melding of datagrids and treeviews, but is ultimately a pivot grid. OLAP data is the spawn of HitlerSatan, and Microsoft doesn't support such a control by default outside of embedding excel. So messing with data templates and tree controls may be a better bet, especially if you don't need absolute freedom to rearrange. No matter what it will be hard; it can be easier but expensive (Infragistics, since yours is editable, and no one else does that) or harder but free (roll your own). Good luck either way. I'll try to help if you need any.

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.