Improper Rendering of XAML?

I’m working on a project right now and have noticed that XAML seems to be incorrectly rendered in the Visual Studio designer, versus it properly being shown in the Expression Blend 3. 

It seems that sizes and alignments are completely off in Visual Studio 2008 where everything appears correct, renders properly, and executes normally when created in Expression Blend 3.

Here’s an example of XAML as rendered in Visual Studio 2008:

image

and in Expression Blend 3:

image

Ignore the black background on the Expression screenshot, but notice that the buttons and all aspects are alligned properly, where the screenshot from Visual Studio 2008 is not.

Here is the XAML source:

If you have seen this happen or know how to fix it, let me know.

  • If you could post a link to the XAML file that exhibits this inconsistent behavior, it would be easier to understand the problem and suggest the solution (or bug fix?).
    Thanks, Rob

    Rob Relyea | WPF & Xaml Language Team
    robrelyea.com | /blog | /wpf | /xaml

  • erick ellis

    Justin – I’m a VS WPF Designer team member and I’ve reproduced your problem with the freshest of VS2010 bits and it is still a problem. I’ve entered an issue to track it, hopefully we can improve the rendering before we ship, but this will llikely still be an issue in Beta2.

    A workaround you could employ, just to make the rendering in the designer more accurate is to remove Window’s size, set a fixed size on Window’s child and set Window.SizeToContent=”WidthAndHeight”.

    This will make the window “shrink-wrap” around the window’s child rather than have window’s borders/etc take up space in the child. Should give you the same layout with better fidelity.

  • Justin

    Thanks Erick. Those few little changes seem to help the rendering; almost appears to fix the problem. Nice workaround.