views:

340

answers:

3

I am looking for a way to populate a single grid using data bindings.

The way I do this at the moment is by using an ItemsControl where each item is represented as a Grid with the columns that I need. The main reason I want a single grid is to make the widths of all columns line up.

Is there way for the Grid panel to be used with ItemsControl so that there is a single grid to contain all the items?

Or is there another solution?

+2  A: 

You can make grid column widths "line up" across grids by using Grid.IsSharedSizeScope and SharedSizeGroup.

You simply need to set the Grid.IsSharedSizeScope property to true on the element that contains your grids, then set the SharedSizeGroup on the ColumnDefinitions you want to have the same width.

Both of the links above have examples.

John Myczek
+2  A: 

Use a ListView with a GridView embedded in the ListView.View property. There are examples of this here and here.

Charlie
I should clarify, I only need the grid for layout, not for selection. So I don't think it does what I need. Thanks anyway.
Ashley Davis
+3  A: 

Why not just use DataGrid?

Pavel Minaev
Is there any sample code that demonstrates how to use this?
Ashley Davis
Pavel Minaev
Ashley Davis