views:

859

answers:

1

Quite often when coming back to Visual Studio from Expression Blend 3, I see that Blend has helpfully added a "d:LayoutOverrides" property to my XAML. Growing up with ASP.NET designers, I naturally distrust anything I wouldn't type myself, so remove them as soon as I see them.

I know that "d:" properties are designer-only and don't impact runtime, but can anyone offer any insight into what this property does and why Blend would be so insistent that I have them all over my markup?

<Border d:LayoutOverrides="Height" />
+11  A: 

That's just there so that Blend knows how to display your XAML in design mode. Specifically, if you've got a fluid layout that stretches to fill its container, there's no clear way for Blend to know how tall your design should be; LayoutOverrides defines that.

Those LayoutOverride settings entries are added when you (or another person running Blend) manually resizes the elements in the design surface. If you're seeing them all over your code (such as in a Border element):

  1. You can usually delete them without any noticable affect
  2. You might look at how you're using Blend - specifically, you should size the parent cotainer to a good size (UserControl / LayoutRoot), then set the child sizes based on fluid layout - e.g. padding and margin or * sizes

Note that Blend's ignorable attributes are stripped out at compile time and have no affect on your application's performance. So while you may want to remove them to improve code readability, they don't affect how your application runs.

Jon Galloway