Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Why not just use DataGrid?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top