WPF XAML special characters (less than, greater than sign, quotation marks, & symbols)

Source: Internet
Author: User

Original: WPF XAML special characters (less than, greater than sign, quotation marks, & symbols)

XAML is limited by XML rules. For example, XML pays special attention to special characters, such as & < > If you try to set an element's content using these characters, you'll get a lot of trouble because the XAML parser thinks you're doing something else--for example, creating a nested element.

For example, suppose you need to create a button that contains <click me> text. The following markup is not able to complete this work:

< ... >    <  Me></Button>

The problem here is that the tag above looks as if you are trying to create an element named Click with an attribute named me. The problem is solved by using entity references instead of special characters, which are specific character encodings that the XAML parser can interpret correctly. The following table lists the possible character entities. Note that you only need to use the quotation mark (") Character entity when setting property values using attributes, because quotation marks are used to indicate the start and end of an attribute value.

XAML character entity
Special characters Character entity
Less than sign (<) &lt;
Greater than sign (>) &gt;
& Symbols (&) &amp;
Quotation marks (") &quot;

The following are the correct tags for using character entities:

< ... >    &lt; Click Me&gt; </ Button >

Reference: http://www.wxzzz.com/?id=125

WPF XAML special characters (less than, greater than sign, quotation marks, & symbols)

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.