How to make a wpf datagrid fill all available space and resize with window?
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>
- Never set height or width to it or its parent control
- No need to worry on the horizontal and vertical alignment since by default Horizontal and vertical alignment are stretch.if above are proper things should work :)
Remove all height and width property of its parent control. remove horizontal and vertical property. Define row height as * of its parent grid.
<Grid> <Grid.RowDefinitions><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions> <DataGrid Grid.Row="0" > </DataGrid></Grid>