Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

silverlight listbox throwing "value not fall in expected range" even when empty?

I'm dynamically populating a silverlight listbox, programmatically, with a template control. the listbox is empty, and when i attempt a listBox.Items.Add(myTemplateControl), it throws the "Value does not fall within the expected range" argumentexception.

i verified in the debugger that the item collection is indeed emtpy. the only time i've heard of this exception happening is when the list already contains an instance with that name.

any thoughts?

Stack trace:

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.Collection_Add[T](PresentationFrameworkCollection`1 collection, Object value)
at System.Windows.PresentationFrameworkCollection`1.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddInternal(Object value)
at System.Windows.PresentationFrameworkCollection`1.Add(T value)
at KTClientRIA.Documents.b__4(Object sender, DownloadStringCompletedEventArgs e)
at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
like image 556
ghost_mv Avatar asked Jan 18 '26 00:01

ghost_mv


1 Answers

Thanks to all the suggestions. I was able to track it down. At another point in time of the life cycle of the silverlight control, there was another listbox completely separate from this one that was adding an item of the same name. being that both the parent listboxes resided on the same silverlight control, it was blowing up.

like image 53
ghost_mv Avatar answered Jan 19 '26 15:01

ghost_mv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!