October 23, 2020, 07:43:12 AM

See more Support incidents in our old archived forum.

Author Topic: NullReferenceException when trying to bring a task into view  (Read 4126 times)

jan.reker

  • Customers
  • Newbie
  • *
  • Posts: 33
NullReferenceException when trying to bring a task into view
« on: March 24, 2015, 09:08:11 AM »
Hello,

I'm sometimes running into an NullReferenceException when trying to bring a task into view and "zoom" the gantt to it. Our application has multiple tabs and i'm trying to bring the tab with the ganttcontrol into view.

I debugged and found in the Method TimeSpanHeader.TimeSpanHeader_Loaded() the line
TimeScaleHeaderDefinition def = this.DataContext as TimeScaleHeaderDefinition;

In this specific case the DataContext is of the type "{DisconntectedItem}" and not of type "TimeScaleHeaderDefinition".

A fix that works for me is to check for !=null before executing further code.

I hope you can include this fix into the library :)

Regards,
Jan

amarnath

  • RQ Members
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #1 on: March 24, 2015, 12:55:24 PM »
Jan,

Thank you very much for pointing out this issue in our Gantt and suggesting fix for it. Sure we will add fix for this into our library.

Still we are very curious to know in which scenario you are getting this issue, could you please help us to reproduce this issue in our samples, which comes along with our .msi install? You can use                 "RadiantQ\ WPF Gantt Install \Samples\ProjectGantt\Appearance\GanttControlTemplateSample1" sample which has multiple tabs in it.

Thanks,
Amar

jan.reker

  • Customers
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #2 on: March 25, 2015, 01:42:05 PM »
Hi,

I think it's not very easy to reproduce in a sample, but I will try to describe the conditions.

We have 2 Tabs, one of them shows the gantt chartt (Tab A) and one e.g a DataGrid (Tab B).
I select an object in Tab B want to jump to this object in the gantt chart in Tab A and switch automatically to Tab A.
Also the time range of the gantt chartt will be adjusted to the length of the objects duration.
Depending on the time range some timeScaleHeaders are visibile and some not. And I think this causes WPF to detach the DataContext.

If I use the "jump to task" function from within Tab A it always works.

I hope this helps a bit.

amarnath

  • RQ Members
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #3 on: March 27, 2015, 07:55:32 AM »
Jan,

Thank you for your explanation, We will try reproducing this and fix it, will get back to you if we need any more clarification.

Thanks,
Amar.

amarnath

  • RQ Members
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #4 on: March 31, 2015, 03:17:00 PM »
Jan,

Please confirm that the new assembly sent to you by email fixes the issue.

Thanks,
Amar

jan.reker

  • Customers
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #5 on: April 01, 2015, 07:31:34 AM »
Thanks for the response, but unfortunately it does not fix the issue.

The code snippet in the email is as following:

TimeScaleHeaderDefinition def = this.DataContext as TimeScaleHeaderDefinition;
if (def.TimeUnitTemplate != null)
   this.ItemTemplate = def.TimeUnitTemplate;

But it needs to be:

TimeScaleHeaderDefinition def = this.DataContext as TimeScaleHeaderDefinition;
if (def != null && def.TimeUnitTemplate != null)
   this.ItemTemplate = def.TimeUnitTemplate;

Regards,
Jan
« Last Edit: April 01, 2015, 07:33:13 AM by jan.reker »

amarnath

  • RQ Members
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #6 on: April 02, 2015, 04:47:39 AM »
Jan,

Our apologies for missing the condition check, we have updated our library and have sent you the latest assembly, could you please conform that this fixes the issue?

Thanks,
Amar

jan.reker

  • Customers
  • Newbie
  • *
  • Posts: 33
Re: NullReferenceException when trying to bring a task into view
« Reply #7 on: April 02, 2015, 07:50:00 AM »
Hi,

the issue is fixed now.

Thanks for your support!