I am writing an application for teachers and students in which a teacher can lookup grades of his students based on a selected subject.
In order to group everything together I have created a dictionary which contains all grades of students in a selected subject (e.g. all grades from Math, it doesn't really matter here):
IDictionary<Class, List<KeyValuePair<Student, List<Grade>>>>
Class is a key to this dictionary which is just a class that students belong to. It has a name of type string that I would like to display (e.g. "4F")
Value is a list that contains a Students from given class and a list of his/her Grades (every Grade has Value and Description, e.g. 3- and "Algebra exam", I would like to display them too).
Basically what I would like to see for every Class (which means for every Key in a dictionary) is something like this (number of students and grades may vary):
- ClassName
- Student
- Grade - Description
- Student2
- Grade - Description
- Grade2 - Description
- Student
I've been looking for a solution, I think it might involve using <TreeView.Resources>
and <HierarchicalDataTemplate>
but to be honest I don't really understand how to use them. I tried one solution and displayed only every ClassName and Students that are connected with a class, but couldn't display anything else. Another solution suggested here: Simple Nested TreeView Xaml structure? left me with:
[SchoolerDatabaseUtilities.Class,System.Collections.Generic.List'1[System.Collections.Generic.KeyValuePair'2[SchoolerDatabaseUtilities.Student,System.Collections.Generic.List'1[SchoolerDatabaseUtilities.Grade]]]]
written for every Key that I had in a dictionary (SchoolerDatabaseUtilities is just a library that I use in order to keep everything in my files clean).
Please help me with anything because I don't even know where to start...
It was suggested that my question was a duplicate of WPF TreeView hierarchical binding. but to me it doesn't seem like it. I was using Dictionary, not a List<>() and it seems to me that my problem was slightly harder in it's nature (whether my approach to a problem was good in terms or readability or not).