XamlStyler icon indicating copy to clipboard operation
XamlStyler copied to clipboard

FormatMarkupExtension always rewrite my bindings on a single line

Open Smallgiil opened this issue 1 year ago • 3 comments

Describe the bug When setting "FormatMarkupExtension": false in my configuration file, XAML Styler still puts my "Binding" attributes on a single line.

To Reproduce Steps to reproduce the behavior:

  1. Create a WPF project with a XAML file.
  2. Make sure the "FormatMarkupExtension" option of XAML Styler is set to false.
  3. Add this in the XAML:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DataTemplate x:Key="DataTemplate1">
        <TextBlock Text="{Binding Path=Name,
                                  UpdateSourceTrigger=PropertyChanged}" />
    </DataTemplate>
</ResourceDictionary>
  1. Format the file (by saving it, for instance).
  2. See that the binding is on a single line: <TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" />

Expected behavior When setting this setting to false, I expect that XAML Styler let me write my bindings on several lines.

External Configuration See the attached configuration file (I had to add a ".json" extension to add it to this issue): Settings.XamlStyler.json

Version Info (please complete the following information):

  • OS: Windows 10 Version 22H2 Build 19045.4894
  • Visual Studio: Professional 17.12.0 Preview 1
  • XAML Styler: 3.2404.2

Smallgiil avatar Sep 23 '24 10:09 Smallgiil

Could we have something that allows comma-separated values to go into newlines? This could come in handy with the Avalonia UI framework as well, specifically with style selectors:

<Style Selector="ContentControl Button,
                 ContentControl StackPanel,
                 ...">
    <Setter Property="IsVisible" Value="True" />
    <Setter Property="Opacity" Value="1" />
</Style>

jpgarza93 avatar Sep 26 '24 19:09 jpgarza93

When setting this setting to false, I expect that XAML Styler let me write my bindings on several lines.

@Smallgiil Can you try the following configuration to see if it achieves the formatting you are looking for?

grochocki avatar Oct 04 '24 07:10 grochocki

@grochocki It does not seem to change much. With the example described in the issue, I still have the same behavior.

Smallgiil avatar Oct 10 '24 16:10 Smallgiil

There is no logic for this. Markup extensions are either outputted as single line or multiple line ( when not in NoNewLineMarkupExtensions ).

Docs should be updated to reflect this https://github.com/Xavalon/XamlStyler/wiki/Markup-Extension-Handling

tonyhallett avatar Jul 15 '25 13:07 tonyhallett