WPF Reflections

Feb 8 2008   3:42PM GMT

ListView – why does ItemTemplate not do anything



Posted by: MarkWPF
WPF

Why does ItemTemplate not do anything?

This is a question that I have asked myself this week, in between banging my head against the wall.

What I wanted to do was apply a template to a row (in a GridView), in addition to the cell templates specified in the Columns attribute in the GridView.
Unfortunately, nothing happens :-(

If you want to do this, you have to use a style instead.
A very good example of this can be found on Bea Costa’s blog

Comment on this Post

Leave a comment:

Matthiasshapiro  |   Feb 8, 2008  4:40 PM (GMT)

The ListView is a freaking monster. My guess is that because the ListView is a decendant of the ItemsControl, it inherits the ItemTemplate property. And while the ItemTemplate property is wonderfully useful in other ItemsControl decendants (like the ComboBox), the ListView does acrobatics in the way it displays data, requiring the use of the ItemContainerStyle and it’s accompanying template to do any styling.

If you have any more questions about the ListView, I’m trying to blog up as much ListView info as possible… drop by and ask a question and I’ll see if I can’t blog an answer.