Recall that you can set the width of a column in a Grid (or height of a row) in three different ways: auto, explicit size, or star sizing.

When you’re using the SharedSizeGroup property to set multiple columns (or rows) to the same width (or height), the method that you use for setting the column width (or row height) affects the final size as follows:

You can force two columns (or rows) in a Grid to always be the same size using the SharedSizeGroup property when defining the columns (or rows).

Below, we specify that the third column should auto-size and that the first and third columns should be the same size. The first column will be sized to match the auto-sized third column. We do the following:

Set Grid.IsSharedSizeScope property of the Grid to true

Set SharedSizeGroup property in the first and third ColumnDefinition elements to the same value (in this case it’s “A”)

A GridSplitter allows a user to change the size of a row or column by dragging a visual splitter. A SharedSizeGroup allows two rows or columns to automatically have the same size. You can combine these concepts, allowing a user to change the size of one column and have another column automatically have the same size.

In the example below, the user can drag either splitter, but when dragging, the width of both left and right columns changes at the same time.

You can use the SharedSizeGroup property of a ColumnDefinition to lead to consistent column sizes in a ListBox with a data template. This works because each entry in the list has its own instance of a Grid and the column sizes are being shared across different grids.

As a more general example, we can share column sizes across two Grid controls hosted in the same window.

The problem with this is that the items don’t line up vertically. We use several StackPanel elements in the data template, which autosize to fit their content. We’d like them to autosize, but to use that same size across all rows, for each column.

We can share sizes between entries using the Grid.IsSharedSizeScope and SharedSizeGroup properties.