Reputation: 1
I am trying to create a grid that consists several columns and rows. Inside of some columns and rows there are datagrids. Here is the question: How can i dynamically resize all grids in different columns and rows while I am enlarging the main window? I created all columns and rows like Height="x*" and Width="y*". In other words rows and columns are being resized while the main window is being resized but grids' size remains the same. I want to enlarge all grids and fill the whole column with the grid. I tried to fix grids' size with * and it did not work. Any idea how can i solve this problem ?
Upvotes: 0
Views: 107
Reputation: 3802
The default layout behaviour of WPF should give you what you expect.
For example, if you have only this in a Window:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Row="0" Grid.Column="0" />
</Grid>
The DataGrid should size with the window as you resize it, occupying exactly a quarter of the window in the top left corner.
Be careful that you aren't setting VerticalAlignment or HorizontalAlignment to something other than "Stretch".
If you mean to ask how to size the columns of the DataGrid dynamically, look at this question.
Upvotes: 0