0

I just need to separate two grous of buttons inside StackPanel with something like:

---------Another Buttons--------

but I need a solid line, note --

curiousity
  • 4,703
  • 8
  • 39
  • 59

2 Answers2

1
<StackPanel Orientation="Horizontal">
    <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />            
</StackPanel>

try this

Gilad
  • 6,437
  • 14
  • 61
  • 119
1

I made a custom control for this.

The code for the Generic.xaml

<Style TargetType="{x:Type local:LineControl}">
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:LineControl}">
            <Border Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Separator Grid.Column="0" VerticalAlignment="Center"></Separator>
                    <ContentPresenter Grid.Column="1" Content="{TemplateBinding Content}" VerticalAlignment="Center"></ContentPresenter>
                    <Separator Grid.Column="2" VerticalAlignment="Center"></Separator>
                </Grid>
            </Border>

        </ControlTemplate>
    </Setter.Value>
</Setter>

The C# code:

public class LineControl : ContentControl
{
    static LineControl()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(LineControl), new FrameworkPropertyMetadata(typeof(LineControl)));
    }
}

And you use it like this

<local:LineControl>
    <TextBlock>test</TextBlock>
</local:LineControl>

The TextBlock can be any control. You can even put a StackPanel with buttons in it if you want.

Martijn
  • 522
  • 1
  • 6
  • 22