Freigeben über


DisplayAttribute.ResourceType Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the type that contains the resources for other localizable property values.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

Syntax

'Declaration
Public Property ResourceType As Type
public Type ResourceType { get; set; }

Property Value

Type: System.Type
The type that contains the resources for other localizable property values.

Remarks

Set the ResourceType property to specify localizable values for the ShortName, Name, Description, Prompt, and GroupName properties.

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.