[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Collapse]MVVM Framework
  [Expand]View Models
   Data Annotation Attributes
   Weak Event
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Data Annotation Attributes

Data Annotation attributes are used for customizing data classes, to specify how data is displayed from a data source, define validation rules, and set relationships between data classes.

The GridControl, TreeListControl, DataLayoutControl and PropertyGridControl recognize Data Annotation attributes, and automatically generate layout and content based on these attributes. These controls support the following attributes from the System.ComponentModel.DataAnnotations library.

  • CreditCardAttribute
  • CustomValidationAttribute
  • DataTypeAttribute
  • DisplayFormatAttribute
  • EditableAttribute
  • EnumDataTypeAttribute
  • EmailAddressAttribute
  • FileExtensionsAttribute
  • MaxLengthAttribute
  • MetadataTypeAttribute
  • MinLengthAttribute
  • PhoneAttribute
  • RangeAttribute
  • RegularExpressionAttribute
  • RequiredAttribute
  • ScaffoldColumnAttribute
  • ScaffoldTable
  • StringLengthAttribute
  • UrlAttribute
  • ValidationAttribute (currently is not supported by DataLayoutControl)

Additionally, the DevExpress.Mvvm.DataAnnotations namespace contains the following attributes for setting masks.

  • DateTimeMaskAttribute
  • NumericMaskAttribute
  • RegExMaskAttribute
  • RegularMaskAttribute
  • SimpleMaskAttribute
  • LayoutControlEditorAttribute

Data Annotation attributes cannot be used to configure automatically generated data classes, e.g., WCF Data Services.

Is this topic helpful?​​​​​​​