DetailViewLayoutAttribute Class
Applied to business class properties. Specifies the Detail View layout options for a target property.
Namespace: DevExpress.ExpressApp.Model
Assembly: DevExpress.ExpressApp.v18.2.dll
Declaration
[AttributeUsage(AttributeTargets.Property)]
public class DetailViewLayoutAttribute :
Attribute
Remarks
In XAF, you can customize the Detail View layout at design-time or runtime using the Model Editor. Alternatively, you can modify the layout in code using DetailViewLayoutAttribute.
This attribute allows you to set the DetailViewLayoutAttribute.ColumnPosition of the current editor to specify the DetailViewLayoutAttribute.GroupId, DetailViewLayoutAttribute.GroupType and DetailViewLayoutAttribute.GroupIndex of the group where this editor will be placed.
Consider the following business class. In this example, we use the Entity Framework Code First class, but a similar approach is applicable to XPO classes as well.
public class Contact {
[Browsable(false)]
public int ID { get; private set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName {
get { return FirstName + " " + LastName; }
}
public string Email { get; set; }
public virtual Contact Manager { get; set; }
public DateTime? Birthday { get; set; }
[FieldSize(FieldSizeAttribute.Unlimited)]
public string Notes { get; set; }
[FieldSize(FieldSizeAttribute.Unlimited)]
public string Remarks { get; set; }
}
By default, SimpleEditors are grouped in two columns if there are more than four editors. Editors from the SizeableEditors group are placed one by one. In the image below, you can see this default layout.
The code below demonstrates how you can customize this default layout using DetailViewLayoutAttribute with different parameters.
public class Contact {
[Browsable(false)]
public int ID { get; private set; }
[DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
public string FirstName { get; set; }
[DetailViewLayoutAttribute(LayoutColumnPosition.Right)]
public string LastName { get; set; }
[DetailViewLayoutAttribute("FullName", 0)]
public string FullName {
get { return FirstName + " " + LastName; }
}
[DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
public string Email { get; set; }
[DetailViewLayoutAttribute(LayoutColumnPosition.Right)]
public virtual Contact Manager { get; set; }
[DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
public DateTime? Birthday { get; set; }
[FieldSize(FieldSizeAttribute.Unlimited)]
[DetailViewLayoutAttribute("NotesAndRemarks", LayoutGroupType.TabbedGroup, 100)]
public string Notes { get; set; }
[FieldSize(FieldSizeAttribute.Unlimited)]
[DetailViewLayoutAttribute("NotesAndRemarks", LayoutGroupType.TabbedGroup, 100)]
public string Remarks { get; set; }
}
Note
If several properties have the same groupId values, their other parameters should be the same as well.
As a result, the layout is changed in accordance with the specified parameters of DetailViewLayoutAttribute.