Silverlight 2 Combobox 有一个bug, 今天被我遇到了,下面是IE错误信息:
Error: Unhandled Error in Silverlight 2 Application
Code: 4004
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& itemsHostRect, Rect& 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)
有人找到了一个应对办法:http://compiledexperience.com/Blog/post/Gotcha-when-databinding-a-ComboBox-in-Silverlight.aspx
试过后可以解决我的问题