Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:47:57+00:00 2026-05-28T07:47:57+00:00

My .NET 4 application uses the WPF TreeView which I have enhanced to enable

  • 0

My .NET 4 application uses the WPF TreeView which I have enhanced to enable keyboard navigation and lazy loading, for example. My problem is that, very rarely, the exception shown below is thrown. This happened to me only once during months of development, and I have bug reports from several customers who also get this once in a while. It is so rare that I cannot change something, play around with the app for a while and know if the problem is gone or not.

But my main question is: the stack trace shows only Microsoft code, there is nothing from me in there. Is this a bug in .NET/WPF? And are there any chances of getting to the root cause?

Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: PresentationFramework
Stack trace:    at System.Windows.Controls.ItemContainerGenerator.ContainerFromIndex(Int32 index)
  at System.Windows.Controls.TreeViewItem.FindNextFocusableItem(Boolean walkIntoSubtree)
  at System.Windows.Controls.TreeViewItem.InternalPredictFocus(FocusNavigationDirection direction)
  at System.Windows.Controls.VirtualizingStackPanel.FocusChanged(KeyboardFocusChangedEventArgs 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.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
  at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
  at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
  at System.Windows.UIElement.Focus()
  at System.Windows.Controls.TreeViewItem.OnItemsChanged(NotifyCollectionChangedEventArgs e)
  at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
  at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
  at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
  at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
  at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
  at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
  at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
  at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
  at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
  at System.Windows.Data.BindingExpression.Activate(Object item)
  at System.Windows.Data.BindingExpression.OnDataContextChanged(DependencyObject contextElement)
  at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
  at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
  at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
  at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
  at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
  at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
  at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
  at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
  at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.RemoveAll()
  at System.Windows.Controls.VirtualizingStackPanel.ClearAllContainers(ItemsControl itemsControl)
  at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.ClearContainerForItem(DependencyObject container, Object item)
  at System.Windows.Controls.ItemContainerGenerator.UnlinkContainerFromItem(DependencyObject container, Object item)
  at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
  at System.Windows.Controls.VirtualizingStackPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
  at System.Windows.Controls.VirtualizingStackPanel.CleanupContainers(Int32 firstViewport, ItemsControl itemsControl)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Border.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Control.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
  at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
  at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Border.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.Controls.Control.MeasureOverride(Size constraint)
  at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  at System.Windows.UIElement.Measure(Size availableSize)
  at System.Windows.ContextLayoutManager.UpdateLayout()
  at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
  at System.Windows.Interop.HwndSource.LayoutFilterMessage(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)
Target: System.Windows.DependencyObject ContainerFromIndex(Int32)
Inner exception message:

Note: I have had this on my machine, too, which runs a fully patched Windows 7 x64.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:47:58+00:00Added an answer on May 28, 2026 at 7:47 am

    I’ve personally never uncovered a bug in WPF. However, stepping into the WPF code has frequently enabled me to trace the source of the problem back to myself.

    Here are some MSDN articles on how to enable debugging Framework source:

    • Visual Studio 2008 version
    • Visual Studio 2010 version

    Link to all versions: https://msdn.microsoft.com/en-us/library/cc667410.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a desktop .NET WPF application witch uses an embedded database (SQLite). Where
I have a .NET application that uses some API calls, for example GetPrivateProfileString .
I have a C# WPF (.NET 4.0) application that uses Excel interop to read
I have a client application (WPF, C#, .net4) which uses POCO entity model connected
I have compiled a .NET application using Any CPU option. This .NET application uses
I have an ASP.NET application that uses a custom .NET library (a .DLL file).
I'm working on a .Net application which uses Asp.net 3.5 and Lucene.Net I am
I'm working on an asp.net application which uses Lucene.net I need to highlight the
I'm having trouble deploying .NET application which uses Microsoft Access automation. I've installed the
I have to integrate a WPF UI into a .NET 2.0 application. ObservableCollection needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.