How to place 'Property' and 'Value' on single line in XAML

How can I format XAML like this:
     <Setter Property="Foreground" Value="White"/>
     <Setter Property="Background" Value="#547AFF"/>

     <Setter Property="Template">
       <Setter.Value>
         <ControlTemplate TargetType="Button">
           <Border Margin="{TemplateBinding Margin}"
             Padding="{TemplateBinding Padding}"
             Background="{TemplateBinding Background}"
           </Border>
         </ControlTemplate>
       </Setter.Value>
     </Setter>

Each attribute in on single line except ‘Property’ and ‘Value’. They should stay on a single line.

What I get after reformatting is like this:

       <Setter Property="Foreground"
         Value="White"/>
       <Setter Property="Background"
         Value="#547AFF"/>

Here Upload id: 2026_02_24_NGK7Fg8DnqCHRPpf2yfHnX (file: Screenshot 2026-02-24 080108.png) are my XML settings.

0
1 comment

Hi Poone Mokariasl

The XML/XAML formatter only lets you choose one of these global attribute layouts for all XML/XAML tags:

  • on_single_line - all attributes stay on one line
  • first_attribute_on_single_line - first attribute with tag name, all others each on their own line (what you’re seeing)
  • on_different_lines - each attribute on its own line
  • do_not_touch - don’t reformat attributes at all

There’s no per-attribute or per-element exception mechanism for XAML setters.

So you can either: 

  • Switch to on_single_line to keep Property and Value together everywhere (but then all attributes will stay on one line), or
  • Keep your current style and accept that ReSharper will split Property and Value across lines, or
  • Set do_not_touch for XML/XAML attributes and format those tags manually.
0

Please sign in to leave a comment.