DataTemplate & DataTemplateSelector Resources: Does the order really matter? RRS feed

  • General discussion

  • I have an app that uses DataTemplate & DataTemplateSelector resources. The one DataTemplate includes an ItemsControl, which also uses DataTemplate & DataTemplateSelector resources. At one point, my app seemed to suddenly stop working, and I finally narrowed it down to the fact that if I removed the ItemTemplateSelector from the nested ItemsControl, it worked (well, except that it didn't have a template). I eventually figured out that if, in the Page.Resources, I put the DataTemplateSelector resources before the DataTemplate resources, it worked. I always thought that the order of the items in a ResourceDictionary was irrelevant, but I guess that's not always true (unless this is a bug). The error I was receiving was useless, so hopefully this will save other people from the frustration I went through in finding the solution.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Sunday, March 1, 2015 6:49 PM