与我之前的问题相关:在Silverlight中绑定ComboBox.SelectedItem
我有一个像这样绑定的ComboBox:
<ComboBox x:Name="PART_CommentaryList"
HorizontalAlignment="Left"
Margin="3"
ItemsSource="{Binding Path=CurrentVideo.Commentaries}"
SelectedItem="{Binding Path=CurrentCommentary, Mode=TwoWay}">
Run Code Online (Sandbox Code Playgroud)
CurrentVideo和CurrentCommentary属性都会定期更改.几次后,我收到此错误:
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 …Run Code Online (Sandbox Code Playgroud)