title: Binding ComboBox.SelectedItem in Silverlight (more)
body: <p>Related to my previous question: <a href="https://stackoverflow.com/questions/855519/binding-combobox-selecteditem-in-silverlight">Binding ComboBox.SelectedItem in Silverlight</a></p>
  
  <p>I have a ComboBox bound like so:</p>
  
  <pre><code>&lt;ComboBox x:Name="PART_CommentaryList" 
      HorizontalAlignment="Left" 
      Margin="3" 
      ItemsSource="{Binding Path=CurrentVideo.Commentaries}" 
      SelectedItem="{Binding Path=CurrentCommentary, Mode=TwoWay}"&gt;
  </code></pre>
  
  <p>Both the CurrentVideo and CurrentCommentary property change regularly. After a few times, I get this error:</p>
  
  <pre><code>Category: ManagedRuntimeError       
  Message: System.ArgumentException: Value does not fall within the expected
     range.
     at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, 
         CValue[] cvData)
     at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, 
         Object[] rawData)
     at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, 
         UIElement visual)
     at System.Windows.UIElement.TransformToVisual(UIElement visual)
     at System.Windows.Controls.Primitives.Selector.IsOnCurrentPage(
         Int32 index, Rect&amp; itemsHostRect, Rect&amp; listBoxItemRect)
     at System.Windows.Controls.Primitives.Selector.ScrollIntoView(
         Int32 index)
     at System.Windows.Controls.Primitives.Selector.SetFocusedItem(
         Int32 index, Boolean scrollIntoView)
     at System.Windows.Controls.ComboBox.PrepareContainerForItemOverride(
         DependencyObject element, Object item)
     at System.Windows.Controls.ItemsControl.UpdateContainerForItem(
         Int32 index)
     at System.Windows.Controls.ItemsControl.RecreateVisualChildren()
     at System.Windows.Controls.ItemsControl.RecreateVisualChildren(
         IntPtr unmanagedObj)
  </code></pre>
  
  <p>This seems like a ComboBox bug to me. I can verify that CurrentVideo changes before CurrentCommentary, so the selected item should always be an item which is in the list.</p>
  
  <p>Related, I really don't want the Mode=TwoWay, because when the ItemsSource is changed, the SelectedItem is temporarily null, which gets set back in my model, which I don't actually want. But the binding doesn't work at all otherwise (which seems like another bug).</p>