wpf WPF矩形绘制边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6782905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF Rectangle draw border
提问by
I need to draw dashed border in Grid Cell. I figured it out using Rectangle, but I need to show only rectangle's bottom border without left, right, or top !!
我需要在网格单元格中绘制虚线边框。我用 Rectangle 弄明白了,但我只需要显示矩形的底部边框,没有 left、right 或 top !
Rectangle r = new Rectangle();
r.StrokeThickness = 1;
r.Stroke = Brushes.Black;
r.StrokeDashArray = new DoubleCollection() { 5 };
r.StrokeDashCap = PenLineCap.Flat;
Thanks!!
谢谢!!
采纳答案by CodeNaked
Looks like you can do it with a Rectangle, if you set the Height to 1 and then vertically align it to the bottom like so:
看起来你可以用一个矩形来做,如果你将高度设置为 1,然后像这样垂直对齐到底部:
<Rectangle Height="1" Stroke="Red" StrokeDashArray="1 2" VerticalAlignment="Bottom" />