This is a migrated thread and some comments may be shown as answers.

ChatView TrackBallBehavior Error "Value cannot be null. Parameter name: key"

4 Answers 147 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
N
Top achievements
Rank 1
N asked on 17 Jan 2013, 10:24 PM
Hi,

I have a line series with ChartTrackBallBehavior set, I use the same line series and change the itemsource programmatically when users picks some other field for display.

Same line series with changing itemsource... After few change in itemsource I get the following error... This seems to happen randomly..This seems to happen if you have the mouse over the chart at one place (i.e without MOVING the mouse) before the lineseries is bound to the new collection.

Is there any way to capture the event something like  MouseOver? of the Chart\LineSeries\TrackBall? and handle the exception otherwise it crashes the application with this unhandled exception.

"Value cannot be null. Parameter name: key"
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.GetPresenterToDataPointInfos(List`1 dataPointInfos) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 754
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.FilterDataPointsByClosestCategoryPerAxis(List`1 dataPointInfos) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 731
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateDataContext(ChartDataContext context) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 373
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateVisuals() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 340
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.OnMouseMove() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 627
   at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.AdornerContainerMouseMove(Object sender, MouseEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 645
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.MouseDevice.Synchronize()
   at System.Windows.Input.MouseDevice.OnHitTestInvalidatedAsync(Object sender, EventArgs e)
   at System.Windows.Input.InputManager.HitTestInvalidatedAsyncCallback(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

4 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 22 Jan 2013, 09:03 AM
Hello,

I am unsure how you are changing the items source. Is it an asynchronous operation in another thread? I think that the best way to go here is to remove the behavior before changing the items and insert it back in after you have changed the items source. Let us know how it goes. 

Regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
N
Top achievements
Rank 1
answered on 23 Jan 2013, 09:21 PM
Thanks Petar, this seems to be working. Doing more tests, will let you know if it does not work.
0
Ian
Top achievements
Rank 1
answered on 10 Apr 2014, 04:30 PM
Hey,

I cam across the forum post because I am having a similar issue, where an exception happens when I clear the series of a chart and replace it with a new series in code, but only when the mouse is over the chart with the track ball behavior attached.

The full exception is at the end of the post.

FYI, I am clearing the behavior as follows:

// Remove any track ball behaviors
var toRemove = (from behavior in instancesOverviewChart.Behaviors
                where behavior is ChartTrackBallBehavior
                select behavior).ToList();
 
foreach (var behavior in toRemove)
{
    instancesOverviewChart.Behaviors.Remove(behavior);
}

And I'm then clearing the series:

instancesOverviewChart.Series.Clear();

Then adding a set of new LineSeries to the chart series and then adding the behavior back:

// Add the behavior back
instancesOverviewChart.Behaviors.Add(new ChartTrackBallBehavior()
{
    ShowIntersectionPoints = true,
    ShowTrackInfo = true
});

This code is running in the UI Dispatcher thread. Any ideas?

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Telerik.Windows.Controls.Chart
  StackTrace:
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateIntersectionPoints(ChartDataContext context)
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateVisuals()
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.OnMouseMove()
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.AdornerContainerMouseMove(Object sender, MouseEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.MouseDevice.Synchronize()
       at System.Windows.Input.InputManager.HitTestInvalidatedAsyncCallback(Object arg)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run()
       at RedPoint.Client.App.Main() in c:\Source\Resonance\Client\_Master\Client\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 



0
Petar Marchev
Telerik team
answered on 14 Apr 2014, 08:15 AM
Hi Ian,

I was unable to reproduce this based on your description. Can you please open a new support thread for this? This is because we do not want to open old threads and because it would make the communication process more clear.

Please open a new support ticked and attach a small project that reproduces this, so that we can investigate and look for solutions. Make sure that you are using the latest version of our controls in order to make sure that you have not encountered a bug that we have already fixed. Thank you.

Regards,
Petar Marchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ChartView
Asked by
N
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
N
Top achievements
Rank 1
Ian
Top achievements
Rank 1
Share this question
or