WPF 矩形 - 圆顶角 [英] WPF rectangle - round just top corners
本文介绍了WPF 矩形 - 圆顶角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能让 WPF 矩形的顶角变成圆角?
How can I have just the top corners rounded for a WPF rectangle?
我创建了一个边框并设置了 CornerRadius
属性,并在边框内添加了我的矩形,但它不起作用,矩形不是圆角的.
I created a border and set the CornerRadius
property and inside the border I've added my rectangle, but it doesn't work, the rectangle is not rounded.
<Border BorderThickness="1" CornerRadius="50,50,0,0" BorderBrush="Black">
<Rectangle Fill="#FF5A9AE0" Stretch="UniformToFill" ClipToBounds="True"/>
</Border>
推荐答案
您遇到的问题是矩形溢出"了边框的圆角.
The problem you've got is that the rectangle is "overflowing" the rounded corners of your border.
矩形不能有单独的圆角,所以如果你只是将背景颜色放在边框上并删除矩形:
A rectangle can't have individually rounded corners, so if you just put the background colour on the border and remove the rectangle:
<Border BorderThickness="1" Grid.Row="0" Grid.ColumnSpan="2"
CornerRadius="50,50,0,0" BorderBrush="Black" Background="#FF5A9AE0">
</Border>
你会得到你想要的效果.
You'll get your desired effect.
这篇关于WPF 矩形 - 圆顶角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文