Training
Module
Customize layout in .NET MAUI XAML pages - Training
Create consistent user interfaces across different devices by using StackLayout and Grid.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article describes layout panels and controls for XAML Designer.
Imagine where you'd like objects to appear on a page—objects such as images, buttons, and videos. Maybe you want them to appear in rows and columns, in a single line vertically or horizontally, or in fixed positions.
After you've had a chance to think about how the page might appear, choose a layout panel. All pages start with one because you need something to which you add your objects. By default it's a Grid, but you can change that.
Layout panels help you arrange objects on a page, but they do more than that. They help you design for different screen sizes and resolutions. When users run your app, everything in a layout panel resizes to match the screen real estate of their device. Of course, if you don't want your layout to do that, you can override that behavior for a part of the layout or the entire layout. You can use height and width properties to control that.
Start your page by choosing one of these layout panels. Your page can have more than one. For example, you might start with a Grid layout panel, and then add a StackPanel to an area in the Grid so that you can arrange controls vertically in that element.
The following layout panels are the most popularly used, but there are others. You can find them all in Toolbox in Visual Studio or the Assets panel in Blend for Visual Studio.
Arrange objects into rows and columns.
Arrange objects into equal, or uniform, grid regions. This panel is great for arranging a list of images.
(Available only for WPF projects.)
Arrange objects any way you want. When users run your app, these elements will have fixed positions on the screen.
Arrange objects in a single line horizontally or vertically.
Arrange objects sequentially from left to right. When the panel runs out of room at the far-right edge, it wraps the content to the next line, and so on from left-to-right, top-to-bottom. You can also make the orientation of a wrap panel vertical so that objects flow from top-to-bottom, left-to-right.
(Available only for WPF projects.)
Arrange objects so that they stay, or dock, to one edge of the panel.
(Available only for WPF projects.)
Watch a short video: WPF - DockPanel
You can add your objects to layout controls as well. They aren't as feature-rich as a layout panel, but you might find them helpful for certain scenarios.
The following layout controls are the most popular, but there are others. You can find them all in Toolbox in Visual Studio or the Assets panel in Blend for Visual Studio.
Create a border, background, or both around an object. You can add only one object to a Border. If you want to apply a border or background for more than one object, add a layout panel to the Border. Then, add objects to that panel or control.
Show information or options to users in a window. You can add only one object to a Popup. By default, a Popup contains a Grid, but you can change that.
Enable users to scroll down a page or area of a page. You can add only one object to a ScrollViewer, so it makes sense to add a layout panel such as a Grid or StackPanel.
Scale objects much like you would with a zoom control. You can add only one object to a Viewbox. If you want to apply that effect to more than one object, add a layout panel to the ViewBox, and then add your controls to that layout panel.
Training
Module
Customize layout in .NET MAUI XAML pages - Training
Create consistent user interfaces across different devices by using StackLayout and Grid.
Documentation
Bind to data in XAML Designer - Visual Studio (Windows)
Bind data to a control in the XAML Designer in Visual Studio by setting data binding properties using the artboard and the Properties window.
Working with elements in XAML Designer - Visual Studio (Windows)
Work with elements in the XAML Designer in Visual Studio or Blend for Visual Studio and add elements—controls, layouts, and shapes—to your app in XAML.
Create and apply a resource - Visual Studio (Windows)
Learn how to create and apply a resource in the XAML Designer so that you can store and reuse styles and templates for elements.