Silverlight Object Disappears if Large Width or Height

January 23, 2009 18:40 by wjchristenson2

After banging my head over this problem for a day, I’ve learned that Silverlight does not support rendering FrameworkElement dimensions larger than Int16.MaxValue (32767).  You may ask why would you ever want object widths or heights larger than 32767?  In most cases, you wouldn’t.  Unfortunately I needed it to and it was a valid business case.  I also have read a few forums where users were trying to view VERY large images or zoom objects and once their dimensions got too large, Silverlight simply couldn’t render them.

I tested this limitation on a few different Silverlight controls and all failed (Rectangle, Canvas, Path, etc).  Next, I tried to draw a line on a canvas which had a start of 0,0 to end of 0,32767.  The line also did not render.  That leads me to think that any object that inherits from FrameworkElement will have this limitation.

I’ve pondered why Microsoft wouldn’t throw an ArgumentOutOfRangeException if it didn’t support such large numbers or even change the Width and Height properties to Int16 instead of a double.  It definitely would have saved me some time.  Happy coding!