Skip to content

External Configurations

Dave Grochocki edited this page Sep 8, 2022 · 20 revisions

A valid XAML Styler configuration is a JSON file with one or more configuration options specified. Below is a complete external configuration that contains the default values.

Set the External Configuration File option to the file path containing the JSON configuration. This path can be a local or network location.

Alternatively, put your external configuration inside a "Settings.XamlStyler" file in any directory up through your solution directory and this configuration will take precedence. XAML Styler will respect the first configuration file it finds in the folder up-hierarchy, so it is possible to use separate configurations for different projects or subdirectories.

Default Configuration

{
    "AttributesTolerance": 2,
    "KeepFirstAttributeOnSameLine": false,
    "MaxAttributeCharactersPerLine": 0,
    "MaxAttributesPerLine": 1,
    "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
    "SeparateByGroups": false,
    "AttributeIndentation": 0,
    "AttributeIndentationStyle": 1,
    "RemoveDesignTimeReferences":  false,
    "IgnoreDesignTimeReferencePrefix": false,
    "EnableAttributeReordering": true,
    "AttributeOrderingRuleGroups": [
        "x:Class",
        "xmlns, xmlns:x",
        "xmlns:*",
        "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
        "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
        "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
        "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
        "*:*, *",
        "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
        "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
        "Storyboard.*, From, To, Duration"
    ],
    "FirstLineAttributes": "",
    "OrderAttributesByName": true,
    "PutEndingBracketOnNewLine": false,
    "RemoveEndingTagOfEmptyElement": true,
    "SpaceBeforeClosingSlash": true,
    "RootElementLineBreakRule": 0,
    "ReorderVSM": 2,
    "ReorderGridChildren": false,
    "ReorderCanvasChildren": false,
    "ReorderSetters": 0,
    "FormatMarkupExtension": true,
    "NoNewLineMarkupExtensions": "x:Bind, Binding",
    "ThicknessSeparator": 2,
    "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin",
    "FormatOnSave": true,
    "CommentPadding": 2,
}

Indent Size

XAML Styler (plugin only) detects and uses Visual Studio indent options by default. However, since xstyler.exe runs independently of Visual Studio, we are unable to detect those options. If you want to override the default behavior for either the plugin or xstyler.exe, you can set an extra property "IndentSize" in an external configuration.

Default Value (plugin): Visual Studio options
Default Value (xstyler.exe): 4

Example:

"IndentSize": 2

Indent With Tabs

XAML Styler (plugin only) detects and uses Visual Studio insertTabs setting by default. However, since xstyler.exe runs independently of Visual Studio, we are unable to detect those options. If you want to override the default behavior for either the plugin or xstyler.exe, you can set an extra property "IndentWithTabs" in an external configuration.

Default Value (plugin): Visual Studio options
Default Value (xstyler.exe): false

Example:

"IndentWithTabs": true

Default Configuration Options

  • AttributeIndentationStyle
    • Mixed = 0
    • Spaces = 1
  • RootElementLineBreakRule
    • Default = 0
    • Always = 1
    • Never = 2
  • ReorderVSM
    • None = 0
    • First = 1
    • Last = 2
  • ReorderSetters
    • None = 0
    • Property = 1
    • TargetName = 2
    • TargetNameThenProperty = 3
  • ThicknessSeparator
    • None = 0
    • Space = 1
    • Comma = 2