XamlStyler
XamlStyler copied to clipboard
Option for controlling number of newlines around elements
Proposal: Two new options for controlling newlines between and around elements.
- An enum of where to put the newlines:
Between
,Surround
,None
, andIgnore
(default) - An integer for choosing the number of newlines
With Between
and newlines 1
, this:
<!-- based on `Local child control style` from wpf-tutorial.com/styles/using-styles -->
<Window x:Class="WpfTutorialSamples.Styles.SimpleStyleSample">
<StackPanel Margin="10">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
<Setter Property="FontSize" Value="24" />
</Style>
</StackPanel.Resources>
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
</Window>
becomes:
<!-- based on `Local child control style` from wpf-tutorial.com/styles/using-styles -->
<Window x:Class="WpfTutorialSamples.Styles.SimpleStyleSample">
<StackPanel Margin="10">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
<Setter Property="FontSize" Value="24" />
</Style>
</StackPanel.Resources>
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
</Window>
Surround
and newlines 1
:
<!-- based on `Local child control style` from wpf-tutorial.com/styles/using-styles -->
<Window x:Class="WpfTutorialSamples.Styles.SimpleStyleSample">
<StackPanel Margin="10">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
<Setter Property="FontSize" Value="24" />
</Style>
</StackPanel.Resources>
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
</Window>
None
:
<!-- based on `Local child control style` from wpf-tutorial.com/styles/using-styles -->
<Window x:Class="WpfTutorialSamples.Styles.SimpleStyleSample">
<StackPanel Margin="10">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
<Setter Property="FontSize" Value="24" />
</Style>
</StackPanel.Resources>
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
</Window>
Visual Studio has Element Spacing
that can preserve, collapse, or remove newlines, but AFAIK no way of adding them.
Thanks for the suggestion! Do you imagine this applying across the board or only the children of certain elements? For example, how would Setters in Style definitions or VisualStates be formatted?
@grochocki Hi! I imagine this being applied on all elements, maybe with an option for exclusions if needed? I've updated the proposal with better examples and a new option to control if newlines should be surrounding elements, or between them.
Great, thanks for adding those details and examples!
Hi, Any news about this issue? I would have a similar request :)
I usually put newlines to organize logical blocks, such as elements with same Grid.Column/Row, or forms, etc. I would like to delete extra newlines and only keep a minimum (default would be 1 line minimum for example).
<StackPanel Margin="10">
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
would become
<StackPanel Margin="10">
<TextBlock>Header 1</TextBlock>
<TextBlock>Header 2</TextBlock>
<TextBlock Foreground="Blue">Header 3</TextBlock>
</StackPanel>
What do you think?
Related to #170
This may build on or supersede #170, but we believe this one might be trickier to implement, especially the between
option. We would like to better understand how this option works before adding it to the project, but are otherwise supportive of this improvement.
BOOM! This was the first feature I looked for.
Has there been any movement on this? I'd love to help but currently I'm so stacked I've no time to dig in.