#82 – How XAML Handles Whitespace

In general, embedded spaces and line feeds in a XAML file are ignored.  You can normally include spaces or line feeds between consecutive items.  Here are some guidelines:

  • You must have at least one space preceding each XAML attribute
  • You must not have any whitespace following the open angle bracket ‘<‘ in an element tag
  • You must not have any whitespace between the ‘/’ and ‘>’ characters in a self-closing element
  • Whereever a namespace prefix is used, with the ‘:’ character, you must not have whitespace on either side of the ‘:’
  • When a property value is expressed as text within quotation marks and it represents textual content, embedded whitespaces and line feeds are preserved.  (E.g. Embedded line feed in a button label)
  • When text is used as a value for a content property, i.e. not in quotation marks
    • All leading and trailing whitespace is removed  (i.e. the string starts with the first non-whitespace character)
    • Internal whitespace is converted to a single space
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: