Back to Devexpress

LayoutControl Class

wpf-devexpress-dot-xpf-dot-layoutcontrol-875d7537.md

latest10.3 KB
Original Source

LayoutControl Class

Represents a control container that arranges its items in a single column or row, and allows you to create compound layouts of controls, with the ability to combine the controls into groups and align the controls according to their labels.

Namespace : DevExpress.Xpf.LayoutControl

Assembly : DevExpress.Xpf.LayoutControl.v25.2.dll

NuGet Package : DevExpress.Wpf.LayoutControl

Declaration

csharp
[DXLicenseWpfEditors]
public class LayoutControl :
    LayoutGroup,
    ILayoutControl,
    ILayoutGroup,
    ILayoutControlBase,
    IScrollControl,
    IPanel,
    IControl,
    ILayoutModelBase,
    ILayoutGroupModel,
    ILiveCustomizationAreasProvider,
    ILayoutControlModel
vb
<DXLicenseWpfEditors>
Public Class LayoutControl
    Inherits LayoutGroup
    Implements ILayoutControl,
               ILayoutGroup,
               ILayoutControlBase,
               IScrollControl,
               IPanel,
               IControl,
               ILayoutModelBase,
               ILayoutGroupModel,
               ILiveCustomizationAreasProvider,
               ILayoutControlModel

Remarks

The LayoutControl container arranges its child items in a single column or row, according to the LayoutGroup.Orientation inherited property. Any types of controls can be added to the LayoutControl container. However, to create compound layouts of controls, you need to combine the controls into LayoutGroups and add the groups as children to the LayoutControl.

The LayoutGroup is a container that arranges its items either side-by-side (in a single column or row) or as tabs. Note that they can display other LayoutGroup objects as children in various orientations. This allows compound layouts to be implemented:

Unlike its predecessor, the LayoutControl doesn’t support a header. So, the LayoutGroup.Header and LayoutGroup.View inherited properties are ignored.

The most common basic element in the LayoutControl is the LayoutItem. This object represents a control consisting of a label and content regions. You can think of the LayoutItem as a wrapper that adds a label to your control. When using LayoutItem objects as wrappers for your controls within a LayoutControl , you benefit from the automatic control alignment feature. To learn more, see Layout Control.

This example demonstrates how to build a compound layout using the LayoutControl.

View Example

xaml
<Window x:Class="LayoutControl_CompoundLayout.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" Title="MainWindow" Height="347" Width="632">

    <Grid x:Name="LayoutRoot" Background="White">
        <lc:LayoutControl Orientation="Vertical" Background="#FFEAEAEA">

            <lc:LayoutGroup Orientation="Horizontal">
                <lc:LayoutGroup Orientation="Vertical">
                    <lc:LayoutItem Label="Item 1:">
                        <TextBox />
                    </lc:LayoutItem>
                    <lc:LayoutGroup Orientation="Horizontal">
                        <lc:LayoutItem Label="Item 2:">
                            <TextBox />
                        </lc:LayoutItem>
                        <lc:LayoutGroup Orientation="Vertical">
                            <lc:LayoutItem Label="Item 3:">
                                <TextBox />
                            </lc:LayoutItem>
                            <lc:LayoutItem Label="Item 4:">
                                <TextBox />
                            </lc:LayoutItem>
                        </lc:LayoutGroup>
                    </lc:LayoutGroup>
                </lc:LayoutGroup>
                <lc:LayoutGroup View="Tabs">
                    <lc:LayoutGroup Header="Tab 1" Orientation="Vertical">
                        <lc:LayoutItem Label="Item 5:">
                            <TextBox />
                        </lc:LayoutItem>
                        <lc:LayoutItem Label="Item 6:">
                            <TextBox />
                        </lc:LayoutItem>
                    </lc:LayoutGroup>
                    <lc:LayoutGroup Header="Tab 2">
                        <lc:LayoutItem Label="Item 7:">
                            <TextBox />
                        </lc:LayoutItem>
                        <lc:LayoutItem Label="Item 8:">
                            <TextBox />
                        </lc:LayoutItem>
                    </lc:LayoutGroup>
                </lc:LayoutGroup>
            </lc:LayoutGroup>
            <lc:LayoutGroup Orientation="Horizontal">
                <lc:LayoutItem Label="Item 9:" HorizontalAlignment="Left">
                    <TextBox Width="100" />
                </lc:LayoutItem>
                <lc:LayoutItem Label="Item 10:">
                    <TextBox />
                </lc:LayoutItem>
                <lc:LayoutItem Label="Item 11:" HorizontalAlignment="Right">
                    <TextBox Width="100" />
                </lc:LayoutItem>
            </lc:LayoutGroup>

        </lc:LayoutControl>
    </Grid>
</Window>

Examples

The following code snippets (auto-collected from DevExpress Examples) contain references to the LayoutControl class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-implement-crud-operations/CS/CodeBehind/EFCore/ServerMode/IssueDetailView.xaml#L8

xml
<Grid>
    <dxlc:LayoutControl x:Name="layoutControl" Orientation="Vertical"
                        VerticalAlignment="Top" Width="300">

reporting-wpf-report-designer-customize-controls-smart-tag/CS/App.xaml#L45

xml
<DataTemplate>
    <dxlc:LayoutControl Width="345" MaxHeight="600">
        <dxlc:LayoutGroup>

wpf-scheduler-use-entity-framework-to-bind-to-data/CS/DXSample/MainWindow.xaml#L36

xml
ItemWidth="300">
<dxlc:LayoutControl Orientation="Vertical">
    <dxe:DateNavigator dxlc:LayoutControl.AllowVerticalSizing="True">

wpf-scheduler-highlight-time-intervals/CS/SchedulerCellTemplate/MainWindow.xaml#L15

xml
<DockPanel>
    <dxlc:LayoutControl DockPanel.Dock="Right" Orientation="Vertical" VerticalAlignment="Top" Padding="0" MinWidth="200">
        <dxe:CheckEdit Content="Highlight Lunch Hours" IsChecked="{Binding HighlightLunchHours, Mode=TwoWay}" Margin="4,0,0,0"/>

wpf-pdf-viewer-draw-a-rectangle-over-a-document/CS/WpfApplication1/MainWindow.xaml#L12

xml
<Grid>
    <dxlc:LayoutControl UseLayoutRounding="True">
        <dxlc:LayoutGroup View="GroupBox">

Inheritance

Show 13 items

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Panel DevExpress.Xpf.Core.PanelBase ScrollControl LayoutControlBase LayoutGroup LayoutControl DataLayoutControl

See Also

LayoutControl Members

Layout Control

Layout Items and Groups

DevExpress.Xpf.LayoutControl Namespace