Is it possible to get controls to automatically divide a space in thirds as the window resizes? It is easy enough to do in code, but I'd like to set the parameters directly in the xaml if possible.
Asked
Active
Viewed 102 times
1 Answers
5
Use the Grid control. It takes up whatever space is available. You can get thirds by doing (assuming you want three columns)
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinitions Width="*"/>
<ColumnDefinitions Width="*"/>
<ColumnDefinitions Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"/>
<Button Grid.Column="1"/>
<Button Grid.Column="2"/>
</Grid>

Shawn Kendrot
- 12,425
- 1
- 25
- 41
-
2+1 and a little [extra reading](http://stackoverflow.com/questions/6956832/what-does-asterisk-mean-in-a-wpf-columndefinition) around the topic. – Adam Houldsworth May 24 '12 at 13:44
-
That answered my question perfectly! Thanks. – Nathan Tornquist May 24 '12 at 13:53