The value of the XML Attribute is always a string, but the object property can be of any. Net type. Therefore, the XAML syntax parser needs to perform a conversion. This conversion is mainly completed by Type converters, which is part of the basic architecture of the full. NET Framework.
Essentially, a type converter mainly has a role in the program ------ it provides a useful method to put the specified.. NET data type to another type or to another type.. net. The XAML parser follows two steps to find the type converter:
1.
It checks the attribute declaration and finds the typeconverter attribute (if any, the typeconverter attribute indicates which classes can be converted ). For example, when you set the foreground attribute,. Net checks the declaration of the foreground attribute.
2.
If the typeconverter attribute is not included in the attribute Declaration, The XAML converter checks the declaration of the corresponding data type class. For example, the foreground attribute uses a brush object. The brush class (and its inheritance class) uses brushconverter, because the brush class uses the typeconverter (typeof (brushconverter) attribute.
If there is no relevant type converter on the attribute declaration or class declaration, The XAML parser will generate an error.