Silverlight does not support Alternating Item Templates in an ItemsControl. I have a few ideas in mind as to how to accomplish this, but to avoid polluting the potential answers, I’ll leave them out.
The idea is the same as a normal ItemTemplate in that it won’t depend on anything in the bound data context to function. I would like the functionality to remain in the View (assuming MVVM)
If you had to design a method of providing alternating templates (and I mean a full data template) for an ItemsControl, how would you accomplish this?
Extend ItemsControl and in the
PrepareContainerForItemOverrideoverride you can apply alternating templates.The way I’m using
alternationIndexis not very accurate and would need to be changed, but otherwise this should work.