[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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)
Thetype exposes the following members.
|TypeConverterAttribute()||Initializes a new instance of the class.|
|TypeConverterAttribute(String)||Initializes a new instance of the 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 class, using the specified type as the data 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.)|
|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.)|
|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 is to provide the processing for setting XAML attributes and generating object values, both for Windows Phone classes and custom classes. You then use to mark a type or member so that the XAML parser can call the TypeConverter implementation as part of its attribute value processing.
When you use 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 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 Windows Phone types use type converter classes as noted by . 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 Load.
To apply a property-specific type converter behavior to a custom attached property, apply to the method that serves as the Get accessor in the implementation pattern for the attached property.