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
Uploaded the RoundedRectangleLibrary here if you want to try it out
http://www.mediafire.com/?44300c4xmy3d1m6
精彩评论