#426 – Layout Panels Can Also Have Margins
November 9, 2011 Leave a comment
You typically set margins on elements contained within a layout panel to create space between different elements and to create space between an element and the edge of the containing panel.
Here’s a Window containing a Grid (beige background), which contains some controls. No margins have been set.
We can then specify a Margin value for the child elements within the Grid. (Here, we set all margins to 5). This creates space between each control and the cell in the Grid that it’s contained in.
We can also specify a Margin value for the Grid itself. Doing so will create space between the Grid and the edges of its container, the Window. In the example below, we specify a Margin of 10 for the Grid. The background of the Window is set to blue, so that we can see the edges of the Grid.