How to make a wpf datagrid fill all available space and resize with window?

user2330678 picture user2330678 · Dec 17, 2013 · Viewed 42.4k times · Source

How to make a wpf datagrid fill all available space and resize with window? Mind that the datagrid is inside a grid.

Answer

Orion Edwards picture Orion Edwards · Dec 17, 2013

You should be able to do it for a datagrid (or for any WPF control) by setting HorizontalAlignment and VerticalAlignment to Stretch

If it's inside a Grid, you should be able to set something like this

<Grid> <!-- parent grid or whatever -->
   <DataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ... >
   </DataGrid>
</Grid>