Rectangle With Only One Border
I am creating a te开发者_运维百科mplate for a button. How do I draw only the bottom border of it?
Thanks!
<Border BorderThickness="0,0,0,1">
<!-- Content -->
</Border>
You can set different thickness for any part of Border
control.
Since you want a dashed line, use a 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 the Dashed line, I'd recommend a Border
with the BorderThickness
property set to 0,0,0,1
You probably want a Border, not a Rectangle in this case.
You could try this make a rectangle of height 1 and vertically align it to bottom
<Rectangle Height="1" Stroke="Red" StrokeDashArray="1 2" VerticalAlignment="Bottom" />
If you only want to have a line at the bottom, you could just have a transparent Border which contains (at some point in the tree) a line.
You shouldn't use either:
- A Rectangle is a Shape (Geometry).
- A Border does not support a dashed line
Instead, I would create a custom Decorator
(Border is a Decorator). You'll be able to customize it how you want and it contains a Child DependencyProperty, so you can wrap it around your content.
精彩评论