ScrollBarValueChanged NullReferenceException

2 posts, 0 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 26 Oct 2012 Link to this post

    Hi,

    I seem to get a NullReferenceException from time to time when I assisigning the ScrollBarValueChanged event. It doesn't always throw the exception, and I can't quite work out how this is happening.
    this.radRichTextBox.VerticalScrollBar.ValueChanged += radRichTextBox_ScrollBarValueChanged;


    I assigned it in my RadRichTextbox loaded event:
    private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
    {
                //Set ListBoxItems
                AutoCompleteSetListBoxItems(1);
                //Set Autocomplete ListBox itemssource
                radListBox.ItemsSource = autoCompleteListItems;
     
                //Assign DocumentArranged event. This will in turn enable document changed event.
                this.radRichTextBox.DocumentArranged += radRichTextBox_DocumentArranged;
     
                //Assign CommandExecuting Event. This will catch cut, copy, paste etc
                this.radRichTextBox.CommandExecuting += radRichTextBox_CommandExecuting;
     
                //Assign Scroll Event To Reposition Popup AutoComplete Window
                this.radRichTextBox.VerticalScrollBar.ValueChanged += radRichTextBox_ScrollBarValueChanged;
    }



    Here's the stack trace:

       at TAS2.RadRichTextBoxAutoComplete.radRichTextBox_Loaded(Object sender, RoutedEventArgs e) in C:\TAS2 - Q3 2012\TAS2\RadRichTextBoxAutoComplete.xaml.cs:line 195
       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.RaiseEvent(RoutedEventArgs e)
       at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
       at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
       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.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, 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.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.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 TAS2.App.Main() in C:\TAS2 - Q3 2012\TAS2\obj\x86\Debug\App.g.cs:line 0



    System.Reflection.RuntimeMethodInfo:
    {Void radRichTextBox_Loaded(System.Object, System.Windows.RoutedEventArgs)}


    Has anyone come across this error before?

    Thanks for your time,

    Rob

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 29 Oct 2012 Link to this post

    Hello Rob,

    We tried reproducing the exception you are observing, unfortunately to no avail. Can you please try to isolate the issue in a sample runnable project and send it to us in a support ticket, so we can further investigate it.

    Thank you in advance!
     
    Kind regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top