Share via


Problems with Nested ItemsControls

As we approach the end of the Orcas project schedule (Visual Studio 2008) I've been doing some app building in order to help validate the quality of the product that we are shipping. 

In doing so, I ran into a WPF bug that actually ended up costing me a fair amount of time. 

I was trying to display a collection of teams where each team had a collection of tasks.  I used an ItemsControl to display the teams and inside the ItemTemplate for each team, I had an ItemsControl that displayed the tasks.

I got the teams showing up but only the first task for the first team showed up.  I went on trying to debug this, using TextBlock set to various binding expressions so that I could see the data as DataBinding would see the data.  After a few hours of finding nothing wrong with my code, I hit the web and found that I had hit on a bug. 

In fact, I found 2 bugs in this area:

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2202842&SiteID=1

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1275132&SiteID=1

There is an illustrative code sample in the forum posting so I didn't bother adding my own in this post.  I did want to raise awareness to this issue as there is a workaround (reference the DataTemplate for the ItemTemplate from resources) and I hope I can save someone some time.

Comments