Silverlight listbox throws “value out of expected range” even when empty?

I am dynamically populating a Silverlight list, programmatically, using a template control. listbox is empty, and when I try listBox.Items.Add (myTemplateControl), it throws an exception to the argument "Value is not in the expected range."

i checked in the debugger that the collection of elements is really emtpy. the only time I heard about this exception is when the list already contains an instance with this 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)
+3
source share
2 answers

. . silverlight , . silverlight, .

+2

, " ", , , .

, ListBox. :

  • UserControl ()
      • AccordionItem0
        • ContentControl
          • ReportView0 ( ContentControl Content)
      • AccordionItem1
        • ContentControl
          • ReportView1 ( ContentControl Content)
      • .

ItemSource ReportView , (, ), "Value ", .

, , , , ReportView ContentControls. , ReportViews AccordionItem, , ReportView .

, ContentControl ReportView . , Silverlight .

( , MEF GetExportedValue. CompositionInitializer.SatisfyImports, ReportView XAML.)

0

All Articles