DisplayAttribute.Description Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets or sets either a resource name or non-localized text, such as a tool tip, that is displayed to users to help them understand a member.
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
Syntax
'Declaration
Public Property Description As String
public string Description { get; set; }
Property Value
Type: System.String
Either a resource name or the non-localized text to display to users to help them understand a member. The resource name is used with the ResourceType property to retrieve localized text to display to users to help them understand a member.
Remarks
Set the Description property to either a literal non-localized string or to a resource name to use with the ResourceType property to retrieve localized text.
Do not use the get accessor of the Description property to retrieve the text to display in your Silverlight application. Instead, use the GetDescription method to retrieve the description to display. The GetDescription method returns either the literal non-localized string or the localized string when a resource type has been specified.
Examples
The following example shows how to use the DisplayAttribute attribute to set both localized and non-localized display values. A property named EmailAddress includes non-localized display values and a property named LastName includes localized display values that are retrieved from a resource type named DisplayResources.
Public Class Customer
<Display(Name:="Email Address", Description:="An email address is needed to provide notifications about the order.")> _
Public Property EmailAddress() As String
'Implement Get and Set logic
End Property
<Display(ResourceType:=GetType(DisplayResources), Name:="LName", Description:="LNameDescription")> _
Public Property LastName() As String
'Implement Get and Set logic
End Property
End Class
public class Customer
{
[Display(Name = "Email Address",
Description = "An email address is needed to provide notifications about the order.")]
public string EmailAddress { get; set; }
[Display(ResourceType=typeof(DisplayResources), Name="LName", Description="LNameDescription")]
public string LastName { get; set; }
}
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also