| MAUI-FlexLayout | MAUI Introduction | |
📐 Layouts in .NET MAUI – FlexLayout |
In the architecture of .NET MAUI (Multi-platform App UI), layouts are the fundamental containers used to compose user interface controls into visual structures. While the framework provides a wide variety of specialized tools, there are eight distinct layout options—six primary built-in classes, a bindable mechanism, and a custom option—that developers use to build responsive cross-platform applications.
Each of these layouts serves a unique purpose, ranging from simple linear stacks to complex, coordinate-based positioning.
The StackLayout is the most basic tool for organizing child elements in a one-dimensional line.
A highly optimized version of the stack layout designed specifically for vertical orientation.
The horizontal counterpart to the vertical stack, optimized for performance.
The Grid is widely considered the most powerful and frequently used layout in .NET MAUI.
Based on the popular web CSS Flexbox module, FlexLayout offers advanced fluidity.
This layout provides the highest level of control by allowing you to specify exact positions.
BindableLayout is technically a set of attached properties that allows any layout class (like a StackLayout or Grid) to generate its children from a data source.
For designs that cannot be achieved with the built-in tools, .NET MAUI allows you to build your own layout logic.
ILayoutManager, you can define exactly how children are measured and positioned.In the modern development landscape, most professional apps use a combination of Grids for the overall page structure and FlexLayouts or StackLayouts for smaller internal components to ensure the app looks great on both mobile phones and desktop monitors. If you are building a highly interactive app, explore the .NET MAUI Community Toolkit for additional layout options like UniformItemsLayout.
| Layout | Description | Best Use Case |
|---|---|---|
| 🧩 StackLayout | Arranges elements in a single line (vertical or horizontal). | Simple forms, menus, linear content. |
| ➡️ HorizontalStackLayout | Optimized stack for horizontal arrangement. | Toolbars, horizontal lists. |
| ⬇️ VerticalStackLayout | Optimized stack for vertical arrangement. | Forms, vertical lists. |
| 🔲 Grid | Organizes content into rows and columns. | Dashboards, structured forms, tabular layouts. |
| 🔧 FlexLayout | Flexible arrangement similar to CSS Flexbox, supports wrapping and alignment. | Responsive layouts, adaptive toolbars, wrapping content. |
| 📍 AbsoluteLayout | Positions elements at exact coordinates or relative bounds. | Overlays, custom positioning, layered UI. |
| 📐 RelativeLayout | Positions elements relative to other elements. | Dynamic layouts where controls depend on each other. |
| 📦 ContentView | Simple container for a single child view. | Reusable UI components, custom controls. |
.NET MAUI provides 8 main layouts. Use StackLayout for simple linear designs, Grid for structured layouts, FlexLayout for responsive designs, and Absolute/RelativeLayout for precise positioning. ContentView is best for reusable components.
| MAUI-FlexLayout | MAUI Introduction | |