Simple (I think) Horizontal Line in WPF?

后端 未结 5 1273
梦毁少年i
梦毁少年i 2020-12-07 12:05

Creating a relatively simple data entry form, and just want to separate certain sections with a horizontal line (not unlike an HR tag in HTML) that stretches the full length

相关标签:
5条回答
  • 2020-12-07 12:14

    Use a Border of height 1 and don't set the Width (i.e. Width = Auto, HorizontalAlignment = Stretch, the default)

    0 讨论(0)
  • 2020-12-07 12:18

    For anyone else struggling with this: Qwertie's comment worked well for me.

    <Border Width="1" Margin="2" Background="#8888"/>
    

    This creates a vertical seperator which you can talior to suit your needs.

    0 讨论(0)
  • 2020-12-07 12:23
    To draw Horizontal 
    ************************    
    <Rectangle  HorizontalAlignment="Stretch"  VerticalAlignment="Center" Fill="DarkCyan" Height="4"/>
    
    To draw vertical 
    *******************
     <Rectangle  HorizontalAlignment="Stretch" VerticalAlignment="Center" Fill="DarkCyan" Height="4" Width="Auto" >
            <Rectangle.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="90"/>
                    <TranslateTransform/>
                </TransformGroup>
            </Rectangle.RenderTransform>
        </Rectangle>
    
    0 讨论(0)
  • 2020-12-07 12:24

    I had the same issue and eventually chose to use a Rectangle element:

    <Rectangle HorizontalAlignment="Stretch" Fill="Blue" Height="4"/>

    In my opinion it's somewhat easier to modify/shape than a separator. Of course the Separator is a very easy and neat solution for simple separations :)

    0 讨论(0)
  • 2020-12-07 12:34

    How about add this to your xaml:

    <Separator/>
    
    0 讨论(0)
提交回复
热议问题