Wednesday, April 9, 2008

Silverlight Xaml error: "Length cannot be less than zero. Parameter name: length"

[This was originally posted at]

I was getting a strange Silverlight compile error in my Page.xaml the other day (while migrating stuff from 1.1 Alpha to 2.0 Beta):

Length cannot be less than zero.
Parameter name: length

At first it sounds like I was setting a wrong value - like trying to reference the "-1" position on a string. But, it actually was a constraint in what namespaces Xaml allows.


In 1.1 Alpha, this would be ok:


Which you could then reference like so:

However, that line kept throwing the error when I tried to compile.


It seems like if I remove the period ".", then it works again, like so:


Strange. I'm not fully sure why, maybe some parsing thing with periods "." in beta, but it was good to have a work-around.