Pre loader

adding LineAnnotation throws null reference

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Closed
0
0

I’m trying to have the user draw a line similar to the Create Annoations Dynamically article.
The line annotation creation starts, but scichart throws a null ref exeception as soon as the user clicks the first line point. The annotation creation method is:

    private void PrepareToAddTrendLine(List<string> objList=null)
    {
        logger.Debug("starting TL");
        sciChart.PreviewMouseLeftButtonUp -= OnMouseLeftClick;//clear
        //setup the next mouse click to place TL
      // view.annotationCreation.AnnotationStyle = (Style)view.Resources[typeof(LineAnnotation)];
        view.annotationCreation.AnnotationType = typeof(LineAnnotation);
        logger.Debug("annotation created");

}

In xaml I have:

                    <s:AnnotationCreationModifier x:Name="annotationCreation"
                                                  ReceiveHandledEvents="True">

                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="AnnotationCreated">
                                <CinchV2:EventToCommandTrigger 
                                            Command ="{Binding OnAnnotationCreated}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </s:AnnotationCreationModifier>

The stack trace is:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Abt.Controls.SciChart.Wpf
StackTrace:
at (Object , IAnnotation )
at A.c3f88e6797399f896ae8b3d5a36c31742.c6dea473323fdce89c6d7460d087afc9c(Object c2e4dcf306e5d5e570ccc0d688db6e42c, IAnnotation c2e4dcf306e5d5e570ccc0d688db6e42c)
at Abt.Controls.SciChart.AnnotationCreationModifier.CreateAnnotation(Type annotationType, Style annotationStyle)
at Abt.Controls.SciChart.AnnotationCreationModifier.OnModifierMouseUp(ModifierMouseArgs mouseButtonEventArgs)
at Abt.Controls.SciChart.ModifierGroup.c9fd5ab524d787e8439d8933aeb87fdc5(IChartModifier c6b1effd112e5355cd5f051dd91cd4f67, ModifierMouseArgs cbb39038dde40bfc3fdcfa70f4bbf8778)
at (Object , IChartModifier , ModifierMouseArgs )
at A.c1eb31c7cf7267e481762980e564f4f72.c6dea473323fdce89c6d7460d087afc9c(Object c2e4dcf306e5d5e570ccc0d688db6e42c, IChartModifier c2e4dcf306e5d5e570ccc0d688db6e42c, ModifierMouseArgs c2e4dcf306e5d5e570ccc0d688db6e42c)
at Abt.Controls.SciChart.ModifierGroup.c9e8960a6a8527c20ac9e46e162c72b22(Action2 c4bd4ab823835cf92d221476b6fb65a17, ModifierMouseArgs c4c23d80d4d060e409c3479ef17d6c65e)
at Abt.Controls.SciChart.ModifierGroup.OnModifierMouseUp(ModifierMouseArgs e)
at Abt.Controls.SciChart.Utility.Mouse.MouseManager.cad56cb88fe961ec17710025afdf79607(ModifierMouseArgs cbb39038dde40bfc3fdcfa70f4bbf8778, IReceiveMouseEvents c18509698be3f9366c690e7d2b107b62c, Boolean c3791a1b71c1577bde30b55c12b2a5583)
at Abt.Controls.SciChart.Utility.Mouse.MouseManager.cf88844ca415efe316ebbc6460c4d5477.c017276be757b162458755f3f8e0c9aa6.cd7319400482f82418e9a97b614eab2ca(IReceiveMouseEvents c133657388cc0f6f6615e21e129ac4b3a)
at A.c3631c672e3fc9e342ac08ff1a63d428e.cacf72b657252e3e73860afb89d70cb9f[c13c28af86f0b14202b9c7ef43b1bd11a](IEnumerable
1 c40a30a1bb6416cd164565919fdef15a9, Action`1 c885aac61bc9832561b7ff07903c88d5e)
at Abt.Controls.SciChart.Utility.Mouse.MouseManager.cf88844ca415efe316ebbc6460c4d5477.cef5451dcf09f913b48c9730b7cb0d11d(Object cae49ecc8585f35e8dd5ce624f7fb7ab5, MouseButtonEventArgs c4c23d80d4d060e409c3479ef17d6c65e)
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.OnMouseUpThunk(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.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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
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 CinchV2DemoWPF.App.Main() in c:\Users\kk\Documents\Visual Studio 2012\Projects\SharpTrading\STGUI\CinchDock\CinchV2DemoWPF\obj\x86\Debug\App.g.cs:line 0
InnerException:


It looks to me like I’m doing it the same way as the article, but I must missing something.

thanks!

  • You must to post comments
0
0

I figured it out. I was binding the surface.Annotations to a viewModel property. That was messing up the annotation creation with the mouse.

  • You must to post comments
Showing 1 result

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies