How can I give a Border
control a dashed border? I also need it to have rounded corners (i.e. CornerRadius
> 0).
Asked
Active
Viewed 2,149 times
1

Jordan
- 9,642
- 10
- 71
- 141
-
1Look right! There are two the same questions here: http://stackoverflow.com/questions/1048137/how-do-i-create-a-dashed-border-with-rounded-corners-in-wpf?rq=1 and http://stackoverflow.com/questions/6195395/how-can-i-achieve-a-dashed-or-dotted-border-in-wpf?rq=1 – Valera Scherbakov Jan 27 '14 at 21:07
-
Check out [here](http://stackoverflow.com/a/6196181/632337). – Rohit Vats Jan 27 '14 at 21:07
-
1The question above, that is supposedly a duplicate of my question, doesn't help me. That includes your link Rohit. I've been there already. You guys are a bit too overzealous with that duplicate question stuff. Be more careful, please. Second, I had been searching on this for an hour before I posted and didn't come by the second link. I didn't know rectangles could be rounded. Good to know, thanks. – Jordan Jan 28 '14 at 13:33
2 Answers
4
<Border>
<Grid>
<Rectangle StrokeDashArray="2.0 2.0" Stroke="Black" RadiusX="3" RadiusY="3" Fill="#FFD267"/>
<!-- put other contents in here-->
</Grid>
</Border>
Can not directly have StrokeDashArray on border, but can get similar effect with the above.

eoldre
- 1,075
- 18
- 28
-
1Since you actually gave me an answer I can work with and didn't give me a speech about duplicating questions, I will select yours. Thanks. – Jordan Jan 28 '14 at 13:35
2
Use a brush like this:
<LinearGradientBrush MappingMode="Absolute"
SpreadMethod="Repeat"
StartPoint="0,0.5"
EndPoint="4,0.5">
<GradientStop Offset="0"
Color="#40000000" />
<GradientStop Offset="0.5"
Color="#40000000" />
<GradientStop Offset="0.501"
Color="Transparent" />
</LinearGradientBrush>

Kcvin
- 5,073
- 2
- 32
- 54