Skip to main content
A newer version of this page is available. .

Document Formatting (XAML)

  • 2 minutes to read

This feature is used to format XAML documents.

Usage

  1. Place the caret into a XAML document.

    NOTE

    The blinking cursor shows the caret's position at which the Code Formatter is available.

    <Window
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
            x:Class="MyWpfApplication.MainWindow" mc:Ignorable="d" 
            Title="MainWindow" Height="350" Width="525">
    <Grid> <Grid>
        <dxm:MapControl> 
            <dxm:ImageLayer> <dxm:OpenStreetMapDataProvider/> </dxm:ImageLayer> 
        </dxm:MapControl>
    </Grid> </Grid>
    </Window>
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Format Document from the menu.

After execution, XAML Document Formatter adds and removes the line breaks and indentations at the required places, so that the indentation of each tag corresponds to its folding level.

<Window x:Class="MyWpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
        Height="350"
        Width="525"
        mc:Ignorable="d"
        Title="MainWindow">

    <Grid>
        <Grid>
            <dxm:MapControl>
                <dxm:ImageLayer>
                    <dxm:OpenStreetMapDataProvider />
                </dxm:ImageLayer>
            </dxm:MapControl>
        </Grid>
    </Grid>

</Window>

Configuration

The configuration options for XAML Document Formatter are available in the Editor | XAML | Formatting options page.

Config_XAML_Formatting

You can configure the following aspects of code formating:

  • Attribute Formatting — configures in which cases and how to break apart the element attributes.
  • Attribute Reordering — switches Attribute Reordering on and off, and configures the desired attributes order.
  • Element Formatting — configures multiple aspects of XAML element formatting.
  • Element Reordering — enables or disables the Grid, Canvas, and Setter sorting.
  • Markup Extension Formatting — configures the formatting options for XAML Markup Extensions.
See Also