WPF Separator(分隔符)

分隔符,如:


 

水平分隔符 XAML

<Separator Style="{StaticResource HorizontalSeparatorStyle}"/>

 水平分隔符 Style

<Style x:Key="HorizontalSeparatorStyle" TargetType="{x:Type Separator}">
    <Setter Property="Background" Value="#dfdddb"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="Height" Value="1"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Separator}">
                <Line Stretch="Fill" X2="1" Stroke="{TemplateBinding Background}" StrokeThickness="{TemplateBinding Height}" StrokeStartLineCap="Square" StrokeEndLineCap="Square"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

 

 

垂直分割符 XAML

<Separator Style="{StaticResource VerticalSeparatorStyle}"/>

 垂直分割符 Style

<!--垂直分隔符-->
<Style x:Key="VerticalSeparatorStyle" 
    TargetType="{x:Type Separator}"
    BasedOn="{StaticResource {x:Type Separator}}">
    <Setter Property="LayoutTransform">
        <Setter.Value>
            <TransformGroup>
                <TransformGroup.Children>
                    <TransformCollection>
                        <RotateTransform Angle="90"/>
                    </TransformCollection>
                </TransformGroup.Children>
            </TransformGroup>
        </Setter.Value>
    </Setter>
</Style>

 

原文参考:https://*.com/questions/13584998/how-to-add-a-vertical-separator

WPF Separator(分隔符)

上一篇:win10开机自启脚本


下一篇:Windows解除指定端口占用