Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 601
user2330678 Avatar asked Dec 17 '13 02:12

user2330678


2 Answers

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> 
like image 151
Orion Edwards Avatar answered Sep 18 '22 18:09

Orion Edwards


  1. Never set height or width to it or its parent control
  2. 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 :)
like image 36
Vishwaram Sankaran Avatar answered Sep 19 '22 18:09

Vishwaram Sankaran