开发者

How do I create a dashed border with rounded top corners in WPF?

开发者 https://www.devze.com 2023-03-29 11:02 出处:网络
I can create a Border element and only make the top corners rounded or I can create a Rectangle element (acting as a border) with 开发者_StackOverflow中文版a dashed stroke.

I can create a Border element and only make the top corners rounded or I can create a Rectangle element (acting as a border) with 开发者_StackOverflow中文版a dashed stroke.

Now how do I create a border that actually can do BOTH these things?

(I do not want rounded bottom corners!)


I created a UserControl which contains a Border whose Background is a VisualBrush made up of four Rectangles, each occupying the same space but has the Clip property set to one of the four corners. Combining these Rectangles and you get a pretty similar effect to what you're after. It also has the relevant Dependency Properties from Border and Rectangle combined

Use it like this

<Controls:RectangleBorder Stroke="Red"
                          StrokeThickess="6"
                          StrokeDashArray="1.0 1.0"
                          CornerRadius="20,20,0,0">
    <Button Content="Test" Margin="5"/>
</Controls:RectangleBorder>

And the result looks like this

How do I create a dashed border with rounded top corners in WPF?

Uploaded the RoundedRectangleLibrary here if you want to try it out
http://www.mediafire.com/?44300c4xmy3d1m6

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号