Hi,
I'm writing tests for the usual reason. I have a XamChart where I've added a drag feature for the user. The user can select a data point and move it up and down. The backing custom class is updated which cascades the update to a XamDataGrid. Everything works fine, but I'm running into problems during testing. Specifically, this line throws an exception:
var hitArgs = xamChart.HitTest(e);
Here is the exception:
System.NullReferenceException was unhandled by user code Message=Object reference not set to an instance of an object. Source=InfragisticsWPF3.Chart.v10.2 StackTrace: at Infragistics.Windows.Chart.XamChart.HitTest(MouseEventArgs e) at Intel.Wolf.UI.WPFMVApp.Helpers.XamChartHelper.MouseLeftButtonDownHandler(Object sender, MouseButtonEventArgs e) in C:\<...>\Helpers\XamChartHelper.cs:line 95 InnerException:
If I run the code in the Immediate Window I get this:
? xamChart == null
false
? e == null
xamChart.HitTest(e)
'xamChart.HitTest(e)' threw an exception of type 'System.NullReferenceException'
base {System.SystemException}: {"Object reference not set to an instance of an object."}
What 'Object'? Neither xamChart or e are null.
Complete method:
private static void MouseLeftButtonDownHandler(object sender, MouseButtonEventArgs e) { var xamChart = sender as XamChart; if (xamChart == null || e == null) return; var hitArgs = xamChart.HitTest(e); selectedDataPoint = hitArgs.SelectedObject as DataPoint; if (selectedDataPoint != null) { xamChart.Cursor = Cursors.SizeNS; started = true; } e.Handled = true; }
Here is my test:
[TestMethod] public void MouseLeftButtonDownHandlerTest() { var chart = new XamChart(); chart.Width = 300; // ??? Create a size to be selected ??? chart.Height = 300; XamChartHelper.SetChartDragging(chart, true); var e = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left); e.RoutedEvent = XamChart.MouseLeftButtonDownEvent; //chart.RaiseEvent(e); XamChartHelper_Accessor.MouseLeftButtonDownHandler(chart, e); // ToDo: Need more logic testing beyond "handled" Assert.IsTrue(e.Handled); }
VS 2010 Ultimate, Win7 x64, InfragisticsWPF3.Chart.v10.2
Can anyone point me in a direction?
Hi Ivan,
I want to let you know we recently fix this issue and now is included in the latest service release available for download form your account here:https://es.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
Please let me know if you have any further questions.
Sincerely,DimiDeveloper Support Engineer, MCPD Infragistics, Inc.www.infragistics.com/support
Hi Dimi,
I am also facing the same issue of Hittest method returnign null. i am using wpf3.chart.v10.3 version. can you help me on this???
Hi Sanjay,
You can download the latest service release for 10.3 version from this link:
https://es.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
The fix for the NullReferenceException will be included in it.
Greetings,
Horen Kirazyan