XAML Auto formatting in Visual Studio 2010

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>
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s