Specifies the class to use as a type converter for the type or property that this attribute is bound to.
Assembly: System (in System.dll)
'Declaration <ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.All, Inherited := True)> _ Public NotInheritable Class TypeConverterAttribute _ Inherits Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.All, Inherited = true)] public sealed class TypeConverterAttribute : Attribute
The TypeConverterAttribute type exposes the following members.
|TypeConverterAttribute()||Initializes a new instance of the TypeConverterAttribute class.|
|TypeConverterAttribute(String)||Initializes a new instance of the TypeConverterAttribute class, using the specified type name as the data converter for the object this attribute is bound to.|
|TypeConverterAttribute(Type)||Initializes a new instance of the TypeConverterAttribute class, using the specified type as the data converter for the object this attribute is bound to.|
|ConverterTypeName||Gets the fully qualified type name of the type to use as a converter for the object this attribute is bound to.|
|Equals||Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
In Silverlight for Windows Phone, this member is overridden by Equals(Object).
In XNA Framework, this member is overridden by Equals(Object).
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Returns the hash code for this instance. (Inherited from Attribute.)
In Silverlight for Windows Phone, this member is overridden by GetHashCode().
In XNA Framework, this member is overridden by GetHashCode().
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Match||When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
The class you use for type conversion must derive from TypeConverter. Use the ConverterTypeName property to get the name of the class that provides the data conversion for the type or member this attribute is bound to.
The most common use of TypeConverter in Silverlight is to provide the processing for setting XAML attributes and generating object values, both for Silverlight classes and custom classes. You then use TypeConverterAttribute to mark a type or member so that the XAML parser can call the TypeConverter implementation as part of its attribute value processing. For more information, see TypeConverters and XAML.
When you use TypeConverterAttribute to mark a type or member, you can either use a string that names the type (must be fully qualified) or a Type to identify the type converter. If you use Type, you generally include a typeof() within the construction behavior of the attribute.
A TypeConverterAttribute is primarily used for two cases: marking a custom class that is used as the property type of one or more custom properties, or marking individual custom properties. Marking individual custom properties gives you the option of using some existing type for your property type, even if that type does not have attribute usage (or any XAML usage at all) as part of its characteristics. So long as that type is constructible by some means, you can use whatever string input is passed to your type converter in order to determine the construction specifics, then return the object to the property.
Not all Silverlight types use type converter classes as noted by TypeConverterAttribute. In some cases, there is type conversion behavior that is native. If you need access to converted values, you might need to use XAML parsing behavior to access the native conversion. See Using XamlReader.Load.
To apply a property-specific type converter behavior to a custom attached property, apply TypeConverterAttribute to the method that serves as the Get accessor in the implementation pattern for the attached property. For more information, see Custom Attached Properties.
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Supported in: Xbox 360, Windows Phone OS 7.0
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.