I've based my code on the RecurringTask example project.
I was able to get my desired visual result but I've now discovered an action that causes my application to crash.
This makes it pretty much unusable, so I need to find a solution or at least a way to catch the exception and prevent it from crashing.
I've been able to pinpoint the cause of my problem, but have been unable to solve this by myself.
Let me start by describing my current situation/environment.
In the RecurringTask_WPF example project if you collapse the "Recurrence Series" (the parent tree node) then you can see all the child recurring tasks next to each other.
When you click on one of the events, so for example: "Recurrence 1" block (in the TimeRuler Part of the RadGanttView), then this specific recurring task gets selected. This causes the tree node to be expanded automatically and the selected task/event becomes highlighted.
This behaviour works perfectly as intended and I wish to keep it like that exactly.
However once you nest recurring tasks into one extra level of hierarchy, which is on my requirements, an exception is thrown and the program stops working.
First I'll give you the code that changes the example project in order to recreate the problem. (This should also help with explaining the exact problem)
You should replace the GetTasks() method of the ViewModel.cs with the code below:
When you run the example with these code changes, you should see that the "Recurrence 3" task now is moved into a new "Recurrence Series2".
This new series is also a child of the original "Recurrence Series1".
So when then all the nodes become collapsed you can still see all child recurrences next to each other.
If you now click on the "Recurrence 3" event (in the TimeRuler Part of the RadGanttView) the application will throw a System.NullReferenceException.
This is the StackTrace (it is in Dutch, but I believe it should still be readable):
Here are some other observations that might help you find the exact cause of this problem:
- If you were to click any other recurring task then the program would keep working as expected.
- If only the top note is collapsed and the child "Recurrence Series2" stays expanded, then the behaviour also keeps working as expected
It would seem that the problem only occurs when nested nodes are collapsed and a child task of a hierarchy that is at least 2 levels deep gets selected.
Now I would just like to find a way to stop my program from crashing.
I've tried handling click events in order to prevent the user from clicking on events in the TimeRuler Part of the RadGanttView, but I wasn't able to figure out how to and I would also still like to keep the behaviour of the automatic expanding and selecting the specific task.
I've also tried to implement a click-command which showed me that the expanding actually works correctly and the exception only occurs afterwards.
Any help would be very much appreciated.