How to Enable/Disable the TrackBall Behavior

3 posts, 0 answers
  1. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 23 Oct 2012 Link to this post

    Hi,

    I'm version 2012.3.1017.40 and trying to enabled the TrackBar Behavior on a double-click on the chart's data area and then disable it with another double click.  I keep getting an exception when I try to disable it.  I'm wondering if this is a bug with the control, or is it the way I'm trying to disable it?

    Here is how I'm trying to Enable/Disable the TrackBall behavior:
     
    private void radCartesianChart1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {      
      
          int index = -1;
      
          for (int i = 0; i < radCartesianChart1.Behaviors.Count; i++)
          {
            if (radCartesianChart1.Behaviors[i] is ChartTrackBallBehavior)
            {
              index = i;
              break;
            }
          }
      
          var mousePosition = e.GetPosition(this);
          Telerik.Charting.DataTuple tuple = radCartesianChart1.ConvertPointToData(mousePosition);
      
          //make sure the double-click occurred in the chart data area
          if (Convert.ToSingle(tuple.FirstlValue) > 0 && Convert.ToSingle(tuple.SecondValue) > 0)
          {
            if (_ShowTrackBall == false)
            {
              //create the TrackBallBehavior and add
              if (index == -1)
              {
                ChartTrackBallBehavior tb = new ChartTrackBallBehavior();
                tb.ShowIntersectionPoints = true;
                tb.ShowTrackInfo = true;
                radCartesianChart1.Behaviors.Add(tb);
      
                _ShowTrackBall = true;
              }
            }
            else
            {
              if (index != -1)
              {
                ChartTrackBallBehavior tb = radCartesianChart1.Behaviors[index] as ChartTrackBallBehavior;
                radCartesianChart1.Behaviors.Remove(tb);
      
                _ShowTrackBall = false;
              }
            
          }  
        }

    It throws an System.ArgumentNullException, {"Value cannot be null.\r\nParameter name: key"},  when I try to disable it with the following StackTrace:
       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\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 697
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.FilterDataPointsByClosestCategoryPerAxis(List`1 dataPointInfos) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 674
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateDataContext(ChartDataContext context) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 371
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.UpdateVisuals() in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 345
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.OnMouseMove() in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 570
       at Telerik.Windows.Controls.ChartView.ChartTrackBallBehavior.AdornerContainerMouseMove(Object sender, MouseEventArgs e) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartTrackBallBehavior.Branch.cs:line 588
       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.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp)
       at System.Windows.Input.MouseDevice.Capture(IInputElement element, CaptureMode captureMode)
       at System.Windows.UIElement.CaptureMouse()
       at Telerik.Windows.Controls.ChartView.ChartPanAndZoomBehavior.AdornerContainerMouseLeftButtonDown(Object sender, MouseButtonEventArgs e) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Behaviors\ChartPanAndZoomBehavior.Branch.cs:line 256
       at System.Windows.Input.MouseButtonEventArgs.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.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.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.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(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.InvokeImpl(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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at delete_TelerikGridViewTest.App.Main() in C:\Users\dkepple\documents\visual studio 2010\Projects\delete_TelerikGridViewTest\delete_TelerikGridViewTest\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

    dd

    Thanks,
    David
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 25 Oct 2012 Link to this post

    Hi David,

    I created a test application, using the MouseDoubleClick event handler you provided, but I could not reproduce the bug you are reporting. I have attached the sample project for reference.
    Could you provide a modified version of the project by attaching it in a formal support thread, so that we can track-down the problem locally?

    Regards,
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Hi Petar,

    I was making lots of code changes to my application and magiclly this appears to have gone away :)

    Thank for providing me a sample though.

    David
Back to Top