A vertical Separator control in a Menu, Toolbar, StackPanel, etc. - Is it possible?

最后都变了- 提交于 2019-12-03 18:29:58

问题


I want to use the Separator control in a vertical way (Lets say in a horizontal StackPanel).

Searching around I found this method but it doesn't use the Separator control rather it uses borders and rectangles. https://social.msdn.microsoft.com/forums/en-US/wpf/thread/eab865be-ad9b-45ed-b9d8-fc93f737b163

Is it possible to use the Separator control in a vertical way?


回答1:


Also:

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



回答2:


Vertical Separator

<Style x:Key="VerticalSeparatorStyle" 
       TargetType="{x:Type Separator}"
       BasedOn="{StaticResource {x:Type Separator}}">
    <Setter Property="Margin" Value="6,0,6,0"/>
    <Setter Property="LayoutTransform">
        <Setter.Value>
            <TransformGroup>
                <TransformGroup.Children>
                    <TransformCollection>
                        <RotateTransform Angle="90"/>
                    </TransformCollection>
                </TransformGroup.Children>
            </TransformGroup>
        </Setter.Value>
    </Setter>
</Style>

Which can be used like this

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


来源:https://stackoverflow.com/questions/4011571/a-vertical-separator-control-in-a-menu-toolbar-stackpanel-etc-is-it-possib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!