by vyurtyn
23. September 2011 18:37
Remember those days when your HTML code was auto-formatted in early versions of Visual Studio? While I don’t miss this feature (who does?
) there is an auto-format option for XAML in Visual Studio 2010 I usually turn on as it improves readability of XAML.
The option is somewhat hidden in configuration of VS2010: select Tools >> Options >> Text Editor >> XAML >> Formatting >> Spacing >> and check “Position each attribute on a separate line”.
Now compare Snapshot A below showing default XAML code in VS 2010 editor (see how you have to scroll back and forth to make any sense of XAML) with the Snapshot B showing the formatted version of the same XAML.
Snapshot A: Default Formatting of XAML

Snapshot B: Formatted XAML

To format a section of XAML just select it and either use the hot-keys “CTRL-E, F” or select Edit >> Advanced >> Format Selection in the Menu.