Rectangle with one border

I am creating a template for a button. How to draw only the bottom border?

Thanks!

+6
source share
6 answers

You can try making a rectangle with a height of 1 and vertically align it from the bottom

<Rectangle Height="1" Stroke="Red" StrokeDashArray="1 2" VerticalAlignment="Bottom" /> 
0
source
 <Border BorderThickness="0,0,0,1"> <!-- Content --> </Border> 

You can set a different thickness for any part of the Border control.

+19
source

Since you need a dashed line, use the Line object and set it to the bottom of your control

  <Line Stroke="Red" Height="2" Stretch="Fill" X2="1" StrokeDashArray="1 2" VerticalAlignment="Bottom" /> 

If you don't need a dashed line, I would recommend Border with the BorderThickness property set to 0,0,0,1

+6
source

You probably want Border , not a rectangle in this case.

+4
source

If you want to have only a line at the bottom, you can just have a transparent border that contains (at some point in the tree) the line.

0
source

You should not use:

  • A rectangle is a shape (geometry).
  • The border does not support the dotted line.

Instead, I would create a custom Decorator (Border). You can customize it the way you want, and it contains a child DependencyProperty, so you can wrap it around your content.

0
source

Source: https://habr.com/ru/post/897925/


All Articles