views:

650

answers:

3

Is it possible to group items in a ItemsControl or Listbox in Silverlight? These controls are bound to a DomainDataSource.

Or are there any 3rd party controls that do this?

UPDATE:

This is the sort of UI I am trying to create.

alt text

A: 

The DataGrid control supports grouping.

Tim Heuer has a good blog on grouping with a datagrid. link text

Stephen Price
Yes I know, but the datagrid is not really suitable for what I want. I want to show a single control(eg Button) for each row but these need to wrap horizontally rather than vertically. So in the ItemsControl you can style the ItemsPanel to use a wrappanel but I cant see a way to do this in the datagrid.
geoff
A: 

Perhaps the control you are really looking for is the Accordian Control from the Toolkit.

See sample of Accordian behaviour here.

Note that the actual appearance is as style-able as any other control. The basic function is to group categories of items that would otherwise be a straight-forward List.

AnthonyWJones
Thanks, I'll take a look. I'm not sure that this will support grouping from a domaindatasource though. Also I need more than 1 level of grouping.
geoff
Hmm.. I see from you comment to Stephen your true requirement and question is kinda of revealed. Its not clear exactly how the idea of "Grouping" is compatiable with a "Wrappanel" style layout? I suggest you edit your question state categorically what actual UI you really want to acheive.
AnthonyWJones
@AnthonyWJones- I've added a image of what I am trying to create. I was looking for a control to do this using databinding but it looks like I am just going to have to write some code to manually create the UI.
geoff
A: 

Check the solution from David Ans http://blogs.msdn.com/b/delay/archive/2010/03/17/confessions-of-a-listbox-groupie-using-ivalueconverter-to-create-a-grouped-list-of-items-simply-and-flexibly.aspx

Valentin Stoychev
@Valentin - thanks, I'll take a look when I have a chance and see if this works for my situation.
geoff