4

On button click, Updating the ListBox ItemsSource collection. For 4 or 5 clicks its working fine but afterwards it throws an exception as '[Unknown]' property does not point to a DependencyObject in path '(0).(1)[1].(2)'

I googled it & find the reason for it.

"The ElementControl overrides PrepareContainerForItemOverride and calls PrepareModel to insert a mesh into _modelContainer for each Item. Later in ElementFlow.BuildTargetPropertyPath (which is called via ElementFlow.SelectItemCore -> LayoutBase.SelectElement -> ElementFlow.PrepareTemplateStoryboard) it is assumed that such a mesh has been inserted into _modelContainer. This exception occurs when the mesh has not been inserted into _modelContainer. WPF calls PrepareContainerForItemOverride on ApplyTemplate. This is only done once. Items added later are never processed like that. "

So please provide me a solution to overcome it.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
rohanw
  • 71
  • 1
  • 4

1 Answers1

1

It seems like maybe there is an item in your " itemsource collection" that is not of the right type, or does not contain one of the properties that your listbox itemstemplate is looking for. Or, perhaps if you have different classes in your collection, one of them may not have the property you are looking for as a DependencyProperty. If it is just a plain property, it may not work correctly.

Check all object types that are going into your itemssource collection and make sure they all have DependencyProperties that are named what the itemstemplate is looking for.

Curtis
  • 5,794
  • 8
  • 50
  • 77