views:

201

answers:

2

How can I add column headers to a Silerlight ItemsControl? I need a fast way to display a List of items that contains also some header info.

A: 

This may seem like a simplistic question but why not use the DataGrid in readonly mode?

The downside with data grid is it doesn't use a virtualised ItemsControl so performance may suffer if you are trying to list hundreds of items with many columns.

AnthonyWJones
I list 500 items in a datagrid and my VirtualizationMode is set accordingly. I also use the enabling of the GPU feature to speed through my datagrid no matter the amount of rows.http://blogs.silverlight.net/blogs/msnow/archive/2009/04/01/silverlight-tip-of-the-day-104-how-to-enable-gpu-acceleration.aspx
Tacoman667
@Tacoman667: I didn't know DataGrid has a VirtualizationMode. However I have discovered there is UI virtualization but not data virtualisation so the situation may not be so bad. My testing was on SL 4 which is still Beta and hence probably not a good measure of performance anyway.
AnthonyWJones
A: 

There's nothing built into the ItemsControl itself, but there's nothing to stop you from making a custom control that has that kind of functionality. It's a little work up front for the ability to reuse it later if it's a piece of UI you need frequently.

Adding too much functionality to it might be overkill though; if you need column sorting or automatic column/header generation, you may find that a DataGrid (as Anthony pointed out already) would be a faster way of getting a lot of functionality for free.

Raumornie