Put on attribute per line in XAML files in Silverlight

A XAML file can be unreadable when there are a lot of attributes in controls. Lines are often too long to be displayed on screen (horizontal scrollbar is required).

Visual Studio 2010 offers an option allowing us to put one attribute per line automatically to facilitate code reading. So, when you have written your code, press Ctrl+K+D to format XAML.

To activate this option, go to Tools -> Options, then open Text Editor -> XAML -> Formatting and select Spacing.

Next, check “Position each attribute on a separate line”.

After that, your XAML looks like this :

See also