Search code examples
data-annotationssilverlight-5.0

DataAnnotation [Key] makes a field readonly, is there other?


The Key DataAnnotation makes a field behave as ReadOnly when I use it in a DataForm or DataGrid since it denotes a DataBase key, but what if I just want to make it readonly because it's a calculated field?

Is there another DataAnnotation, other than Key, to make a field behave as ReadOnly in a DataForm?

Window


Solution

  • Try the Editable annotation, with AllowEdit as false.

    [System.ComponentModel.DataAnnotations.Editable(AllowEdit = false)]