Skip to content

Basic Layout and Panel

Roman Shapiro edited this page Jul 26, 2019 · 20 revisions

Every widget has following properties related to the layout:

Name Type Default Description
Left/Top int 0 X/Y Addition
Width/Height int? null Width/Height of the widget, if set to null, then it is automatically calculated
HorizontalAlignment/VerticalAlignment enum Depends on a widget, it's either Stretch or Left/Top How control is horizontally/vertically aligned in the container
PaddingLeft/PaddingTop PaddingBottom/PaddingRight int 0 Padding
GridPositionX/GridPositionY int 0 Position in the grid
GridSpanX/GridSpanY int 1 Span in the grid

_Note. Properties which names start with 'Grid' are used only in the Grid container.

The most simple container is Panel. Following MML demonstrates usage of layout properties with it:

<Project>
  <Panel>
    <TextBlock Text="My Awesome Game" TextColor="#FFA500FF" HorizontalAlignment="Center" />
    <VerticalMenu HorizontalAlignment="Center" VerticalAlignment="Center" >
      <MenuItem Id="_menuStartNewGame" Text="Start New Game" />
      <MenuItem Id="_menuOptions" Text="Options" />
      <MenuItem Id="_menuQuit" Text="Quit" />
    </VerticalMenu>
  </Panel>
</Project>