Skip to content

Case Sensitivity of Xaml

June 12, 2007

Marius Gheorghe complains of Xaml’s case-sensitivity in XAML case sensitivity and XAML case sensitivity.Reloaded where among other things he said:

Case sensitive markup code = pure evil

To tell you the truth, nobody has asked that question of "Why is Xaml case-sensitive" before, and we made the decision so long ago, I had to go talk to Mike Hillberg to get/recreate the reason why Xaml is case sensitive.

First, what is our behavior:

  • Xaml element names and attribute names map directly to Type, Property and Event names in a case-sensitive manner.
  • .Net Framework Design Guidelines (MSDN or book@Amazon) call for Pascal casing of Type, Property and Event names. (initial caps and capitalizing words inside the name as well…for example DrawingImage.)
  • Therefore, you’ll find that Xaml generally needs to be Pascal cased for Element and Attribute names.
  • Attribute values in Xaml are generally case-insensitive.  ("True", "true", or "TrUe" all work for a property of type boolean.)  This is an artifact of the fact that we call TypeConverters to convert attribute values into the appropriate type, and most .Net type converters are type insensitive.

A few reasons:

XHTML is case sensitive, where as HTML is not case sensitive. Furthermore XHTML requires that all enumerated attribute values be lower case.

[Note, Xaml,  as noted earlier, is a bit looser with attribute values…most attribute values are case-insensitive, but that is up to the TypeConverter which is used for that property value.  We recommend that TypeConverters are case-insensitive unless they must be case-sensitive.  Path.Data is one of the few case-sensitive attribute values that WPF has.]

  • The XHTML spec says why they made that choice:

XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.

Given that we needed to make a choice, we felt that consistency of casing between the type definition and the use in Xaml was the most natural choice.

So that is where we are and why. Thanks to Marius for asking the question and giving the feedback. So far, Marius’ is the first mention I remember seeing of this since we’ve been published "Avalon" externally in October of 2003.  I agree that hand editing of Xaml is harder due to this behavior.

From → XAML (non-UI)

8 Comments
  1. Unknown permalink

    We provide all Wow gold services. You can buy wOW Gold, Cheap woW gold here. We provide Cheap wOW Gold to each loyal and reliable customer.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: