How Silverlight converter works

Source: Internet
Author: User
Tags xml attribute

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.