title: Why does ObservableCollection throws an exception when being modified?
body: <p>My application uses a WPF <code>DataGrid</code>. One of the columns is a template column that contains a <code>ComboBox</code> bound to an <code>ObservableCollection</code> of the entity which feeds the row. When I add a value to the <code>ObservableCollection</code>, a <code>NullReferenceException</code> is thrown.</p>
  
  <p>Has anybody an idea why this happens? Here is the stack trace of the exception:</p>
  
  <pre>
     at MS.Internal.Data.PropertyPathWorker.DetermineWhetherDBNullIsValid()
     at MS.Internal.Data.PropertyPathWorker.get_IsDBNullValidForUpdate()
     at MS.Internal.Data.ClrBindingWorker.get_IsDBNullValidForUpdate()
     at System.Windows.Data.BindingExpression.ConvertProposedValue(Object value)
     at System.Windows.Data.BindingExpressionBase.UpdateValue()
     at System.Windows.Data.BindingExpression.Update(Boolean synchronous)
     at System.Windows.Data.BindingExpressionBase.Dirty()
     at System.Windows.Data.BindingExpression.SetValue(DependencyObject d, DependencyProperty dp, Object value)
     at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
     at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
     at System.Windows.Controls.Primitives.Selector.UpdatePublicSelectionProperties()
     at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
     at System.Windows.Controls.Primitives.Selector.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.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
     at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
     at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
     at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
     at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
     at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
     at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
     at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
     at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
     at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
     at System.Collections.ObjectModel.Collection`1.Add(T item)
     at ORF.PersonBook.IdentityModule.Model.SubsidiaryModel.AddRoom(RoomModel room) in C:\Project\Phoenix\Development\src\ORF.PersonBook.IdentityModule\Model\SubsidiaryModel.cs:line 127
  </pre>