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 (<) |
< |
Greater than sign (>) |
> |
& Symbols (&) |
& |
Quotation marks (") |
" |
The following are the correct tags for using character entities:
< ... > < Click Me> </ Button >
Reference: http://www.wxzzz.com/?id=125
WPF XAML special characters (less than, greater than sign, quotation marks, & symbols)