To Auto format XAML code in a readable and organized way
1. Open Visual Studio 2010
2. Go to Menu: Tools->Options
3. Select
Text Editor
|->XAML
|->Formatting
|->Spacing
4. Set the options 1 & 2 as shown in the below image
Sample Code:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<!--Before Auto formatting -->
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="66,52,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
<!--After Auto formatting -->
<Button Content="Button"
Height="23"
HorizontalAlignment="Left"
Margin="248,68,0,0"
Name="button2"
VerticalAlignment="Top"
Width="75" />
</Grid>
</Window>
