I like to use the Line control. It gives you precise control of where the separator begins and ends. Although this is not exactly a separator, it works the same way, especially in the StackPanel.
Line management also works in a grid. I prefer to use StackPanel because you do not need to worry about overlapping different controls.
<StackPanel Orientation="Horizontal"> <Button Content="Button 1" Height="20" Width="70"/> <Line X1="0" X2="0" Y1="0" Y2="20" Stroke="Black" StrokeThickness="0.5" Margin="5,0,10,0"/> <Button Content="Button 2" Height="20" Width="70"/> </StackPanel>
X1 = start position x (should be 0 for a vertical line)
X2 = x end position (X1 = X2 for the vertical line)
Y1 = y initial position (should be 0 for a vertical line)
Y2 = y end position (Y2 = desired line height)
I use margin to add padding on either side of the vertical line. In this case, there are 5 pixels to the left and 10 pixels to the right of the vertical line.
Since line management allows you to select the x and y coordinates of the beginning and end of a line, you can also use it for horizontal lines and lines at any angle between them.
Kevin K Jun 19 '16 at 4:50 2016-06-19 04:50
source share