wpf-devexpress-dot-xpf-dot-layoutcontrol-7cc0606e.md
A data-bound version of the LayoutControl.
Namespace : DevExpress.Xpf.LayoutControl
Assembly : DevExpress.Xpf.LayoutControl.v25.2.dll
NuGet Package : DevExpress.Wpf.LayoutControl
[DXLicenseWpfEditors]
public class DataLayoutControl :
LayoutControl
<DXLicenseWpfEditors>
Public Class DataLayoutControl
Inherits LayoutControl
The DataLayoutControl is a data-bound version of its ancestor - the LayoutControl. The DataLayoutControl provides an easy way to create a layout for editing public properties of a bound object (DataLayoutControl.CurrentItem).
Refer to the following help topic for more information: Data Layout Control.
The following code snippet uses the Data Layout Control to display the data:
<Window x:Class="DataLayoutControl.View"
...
xmlns:local="clr-namespace:DataLayoutControl"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<dxlc:DataLayoutControl CurrentItem="{Binding SelectedObject}"/>
</Grid>
</Window>
using System;
using System.ComponentModel.DataAnnotations;
namespace DataLayoutControl {
public class Person {
[Display(GroupName = "<Name>", Name = "Last name")]
public string LastName { get; set; }
[Display(GroupName = "<Name>", Name = "First name", Order = 0)]
public string FirstName { get; set; }
[Display(GroupName = "Contact", Order = 2), DataType(DataType.PhoneNumber)]
public string Phone { get; set; }
[Display(GroupName = "Contact", Order = 4)]
public string Email { get; set; }
[Display(GroupName = "Contact/Address", ShortName = "")]
public string AddressLine1 { get; set; }
[Display(GroupName = "Contact/Address", ShortName = "")]
public string AddressLine2 { get; set; }
[Display(GroupName = "Personal", Name = "Birth date")]
public DateTime BirthDate { get; set; }
[Display(GroupName = "Personal", Order = 3)]
public Gender Gender { get; set; }
}
public enum Gender { Male, Female }
}
Imports System
Imports System.ComponentModel.DataAnnotations
Namespace DataLayoutControl
Public Class Person
<Display(GroupName:="<Name>", Name:="Last name")>
Public Property LastName As String
<Display(GroupName:="<Name>", Name:="First name", Order:=0)>
Public Property FirstName As String
<Display(GroupName:="Contact", Order:=2), DataType(DataType.PhoneNumber)>
Public Property Phone As String
<Display(GroupName:="Contact", Order:=4)>
Public Property Email As String
<Display(GroupName:="Contact/Address", ShortName:="")>
Public Property AddressLine1 As String
<Display(GroupName:="Contact/Address", ShortName:="")>
Public Property AddressLine2 As String
<Display(GroupName:="Personal", Name:="Birth date")>
Public Property BirthDate As DateTime
<Display(GroupName:="Personal", Order:=3)>
Public Property Gender As Gender
End Class
Public Enum Gender
Male
Female
End Enum
End Namespace
using DevExpress.Mvvm;
using System;
namespace DataLayoutControl {
public class MainViewModel : ViewModelBase {
public MainViewModel(){
SelectedObject = (new Person{
FirstName = "Carolyn",
LastName = "Baker",
Email = "[email protected]",
Phone = "(555)349-3010",
AddressLine1 = "1198 Theresa Cir",
AddressLine2 = "Whitinsville, MA",
Gender = Gender.Female,
BirthDate = new DateTime(1992, 10, 01)
});
}
public Person SelectedObject { get; set; }
}
}
Imports DevExpress.Mvvm
Imports System
Namespace DataLayoutControl
Public Class MainViewModel
Inherits ViewModelBase
Public Sub New()
SelectedObject = (New Person With {
.FirstName = "Carolyn",
.LastName = "Baker",
.Email = "[email protected]",
.Phone = "(555)349-3010",
.AddressLine1 = "1198 Theresa Cir",
.AddressLine2 = "Whitinsville, MA",
.Gender = Gender.Female,
.BirthDate = New DateTime(1992, 10, 01)
})
End Sub
Public Property SelectedObject As Person
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the DataLayoutControl 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-lookupedit-process-new-values/CS/HowToCreateLookUpEdit/MainWindow.xaml#L17
<DataTemplate>
<dxlc:DataLayoutControl CurrentItem="{Binding}"
Orientation="Vertical"/>
wpf-data-grid-create-filter-ui/CS/WpfApplication27/MainWindow.xaml#L58
</dxg:GridControl>
<dxlc:DataLayoutControl x:Name="myDataLayoutControl" CurrentItem="{Binding Path=FilteringViewModel, ElementName=filteringBehavior}" GroupBoxDisplayMode="Light" ItemSpace="10" AutoGenerateItems="False" AllowBringChildIntoView="False">
<Button Width="150" Height="30" Content="Reset all filters" Command="{Binding FilteringViewModel.City.ResetAllCommand, ElementName=filteringBehavior}" />
<DataTemplate>
<dxlc:DataLayoutControl CurrentItem="{Binding}"
Orientation="Vertical"/>
Show 13 items
Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Panel DevExpress.Xpf.Core.PanelBase ScrollControl LayoutControlBase LayoutGroup LayoutControl DataLayoutControl
See Also