# Layout Panel

The purpose of this article is to describe how the **RadLayoutControl** children are arranged in their panel.

The items panel of **RadLayoutControl** and the **layout groups** is a **LayoutPanel**. So, each group arranges its children in its available space using the same logic. This is why this article won't consider a scenario with nested groups but it will explain the arrangment only in a single panel with its Orientation set to Horizontal. The same principles apply in a vertically oriented panel.

> This article is not relevant for the **LayoutControlTabGroup**. The tab items of the group are always arranged horizontally.

The following rules apply to the children of the **LayoutPanel** with a **horizontal orientation**:

* All **left aligned** items will be stacked at the left side of the panel. The panel will give each item only as much size as it needs.

* All **right aligned** items will be stacked at the right side of the panel. The panel will give each item only as much size as it needs.

> caption Left and right aligned items

```
![WPF RadLayoutControl Left and right aligned items](images/layoutcontrol-getting-started-layoutpanel-01.png)  
Example 1 demonstrates the items setup demonstrated in __Figure 1__.	
```

* After positioning the left and right aligned elements the panel will divide the remaining space between the **stretched** items. The positions of the stretched items varies based on the left/right and the center aligned items, and also on the index  of the item in the panel's children collection.

> caption Stretched items with different sizes

```
![WPF RadLayoutControl Stretched items with different sizes](images/layoutcontrol-getting-started-layoutpanel-02.png)  
Example 2 demonstrates the items setup demonstrated in __Figure 2__.	
```

> caption Stretched and left/rigth aligned items with different sizes

```
![WPF RadLayoutControl Stretched and left/rigth aligned items with different sizes](images/layoutcontrol-getting-started-layoutpanel-03.png)  
Example 3 demonstrates the items setup demonstrated in __Figure 3__.	
```

* All **center aligned** items will be stacked in the center of the panel's available space.

> caption Centered items

```
![WPF RadLayoutControl Centered items](images/layoutcontrol-getting-started-layoutpanel-04.png)  
Example 4 demonstrates the items setup demonstrated in __Figure 4__.	
```

> caption Centered and left/right aligned items

```
![WPF RadLayoutControl Centered and left/right aligned items](images/layoutcontrol-getting-started-layoutpanel-05.png)  
Example 5 demonstrates the items setup demonstrated in __Figure 5__.	

In case there are stretched items in the panel, the center items might look like they are stacked left or right. The positions of the centered items will depend on the collection index of the stretched items.
```

> caption Centered items and a single stretched item inserted at the end of the children collection

```
![WPF RadLayoutControl Centered items and a single stretched item inserted at the end of the children collection](images/layoutcontrol-getting-started-layoutpanel-06.png)  
Example 6 demonstrates the items setup demonstrated in __Figure 6__.	
```

> caption Centered items and a single stretched item inserted at the beginning of the children collection

```
![WPF RadLayoutControl Centered items and a single stretched item inserted at the beginning of the children collection](images/layoutcontrol-getting-started-layoutpanel-07.png)  
Example 7 demonstrates the items setup demonstrated in __Figure 7__.	
```

> caption Centered items and a single stretched item inserted around the middle of the children collection

```
![WPF RadLayoutControl Centered items and a single stretched item inserted around the middle of the children collection](images/layoutcontrol-getting-started-layoutpanel-08.png)  
Example 8 demonstrates the items setup demonstrated in __Figure 8__.	
```

> caption Centered, stretched and left/right aligned items

```
![WPF RadLayoutControl Centered, stretched and left/right aligned items](images/layoutcontrol-getting-started-layoutpanel-09.png)  
Example 9 demonstrates the items setup demonstrated in __Figure 9__.	
```

In summary, the panel allocates space for the left and right aligned items first. Then the available space that is left is given to the center aligned and the stretched items.

> The order of the children in the LayoutPanel depends on their alignment and also their collection index.



> The same rules are valid for a LayoutPanel with **vertical orientation**.

## Code Examples

This section contains the items setup demonstrated in the images in the article.

**Example 1: Left and right aligned items**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left aligned" HorizontalAlignment="Left" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Right" HorizontalAlignment="Right" />
</telerik:RadLayoutControl>
```

**Example 2: Stretched items with different sizes**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Stretch - with bigger size" HorizontalAlignment="Stretch" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Stretch - with bigger size" HorizontalAlignment="Stretch" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
</telerik:RadLayoutControl>
```

**Example 3: Stretched and left/rigth aligned items with different sizes**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left - with bigger size" HorizontalAlignment="Left" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Right" HorizontalAlignment="Right" />
</telerik:RadLayoutControl>
```

**Example 4: Centered items**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
</telerik:RadLayoutControl>
```

**Example 5: Centered and left/right aligned items**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
</telerik:RadLayoutControl>
```

**Example 6: Centered items and a single stretched item inserted at the end of the children collection**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
</telerik:RadLayoutControl>
```

**Example 7: Centered items and a single stretched item inserted at the beginning of the children collection**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
</telerik:RadLayoutControl>
```

**Example 8: Centered items and a single stretched item inserted in the middle of the children collection**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Center" HorizontalAlignment="Center" />
</telerik:RadLayoutControl>
```

**Example 9: Centered, stretched and left/right aligned items**

```XAML
<telerik:RadLayoutControl>
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Left" HorizontalAlignment="Left" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Right" HorizontalAlignment="Right" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Stretch" HorizontalAlignment="Stretch" />
    <Button Content="Center" HorizontalAlignment="Center" />
    <Button Content="Stretched item with bigger size" HorizontalAlignment="Stretch" />
</telerik:RadLayoutControl>
```

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radlayoutcontrol/getting-started/getting-started)
* [Layout Groups](https://www.telerik.com/products/wpf/documentation/controls/radlayoutcontrol/features/layoutgroups/overview)
* [Orientation](https://www.telerik.com/products/wpf/documentation/controls/radlayoutcontrol/features/orientation)
* [Edit the Layout](https://www.telerik.com/products/wpf/documentation/controls/radlayoutcontrol/features/edit-the-layout)
