System.ComponentModel.TypeConverter Class

Provides a unified way of converting types of values to other types, as well as for accessing standard values and subproperties.

See Also: TypeConverter Members


public class TypeConverter


The most common type of converter is one that converts to and from a text representation. The type converter for a class is bound to the class with a System.ComponentModel.TypeConverterAttribute. Unless this attribute is overridden, all classes that inherit from this class use the same type converter as the base class.


For general type system purposes, do not access a type converter directly. Instead, access the appropriate converter by using System.ComponentModel.TypeDescriptor. For more information, see the code examples provided.

Note   For XAML purposes, a XAML processor searches for the System.ComponentModel.TypeConverterAttribute directly, instead of going through System.ComponentModel.TypeDescriptor. For cases where you do want a System.ComponentModel.TypeDescriptor instance from code, or where you create a shared instance in WPF resources, it is acceptable to construct it directly without referencing System.ComponentModel.TypeDescriptor or other reflection and type system support.

Classes derived from System.ComponentModel.TypeConverter are often referenced as part of how a XAML processor converts an attribute or initialization text value from markup (which is inherently a string) and generates an object for a run-time representation. Custom type authors that intend to support a type conversion behavior for XAML typically implement a System.ComponentModel.TypeConverter class that supports their own unique ConvertFrom behavior from a string. This behavior enables type conversion from the string provided as a XAML attribute value and provides a XAML processor with the support needed to create an object from the string, so that the object can be produced in a parsed object graph. Custom types or members of custom types are indicated by applying System.ComponentModel.TypeConverterAttribute to the definitions, with the attribute referencing the custom System.ComponentModel.TypeConverter implementation. For more information, see Type Converters for XAML Overview.


Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,,