DataLayoutControl Class
Namespace: DevExpress.Xpf.LayoutControl
Assembly: DevExpress.Xpf.LayoutControl.v19.2.dll
Declaration
public class DataLayoutControl :
LayoutControl
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).
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;
using System.Windows;
namespace DataLayoutControl
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
public class MainViewModel : ViewModelBase {
public Person SelectedObject {
get { return GetValue<Person>(); }
set { SetValue(value); }
}
public MainViewModel()
{
SelectedObject = (new Person
{
FirstName = "Carolyn",
LastName = "Baker",
Email = "carolyn.baker@example.com",
Phone = "(555)349-3010",
AddressLine1 = "1198 Theresa Cir",
AddressLine2 = "Whitinsville, MA",
Gender = Gender.Female,
BirthDate = new DateTime(1992, 10, 01)
});
}
}
}
Imports DevExpress.Mvvm
Imports System
Imports System.Windows
Namespace DataLayoutControl
Public Partial Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
End Class
Public Class MainViewModel
Inherits ViewModelBase
Public Property SelectedObject As Person
Get
Return GetValue(Of Person)()
End Get
Set(ByVal value As Person)
SetValue(value)
End Set
End Property
Public Sub New()
SelectedObject = (New Person With {
.FirstName = "Carolyn",
.LastName = "Baker",
.Email = "carolyn.baker@example.com",
.Phone = "(555)349-3010",
.AddressLine1 = "1198 Theresa Cir",
.AddressLine2 = "Whitinsville, MA",
.Gender = Gender.Female,
.BirthDate = New DateTime(1992, 10, 01)
})
End Sub
End Class
End Namespace
Refer to the Data Layout Control topic for more information.
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.
See Also