Inverted Corner Radius in WPF (something like a negative Radius)
I try to c开发者_StackOverflowreate a border with a negative Corner radius, like this:
I want the radius on the inside. Is this possible with build in functions or do I have to paint it with a path?
Well I faced the same problem and tried to figure out a solution.
Last but not least I came to the conclusion that it is not possible to solve this with a border
.
I focussed on drawing my Border
with the Path
and the CombinedGeometry
function.
If anyone is still looking for a solution how to make inverted round corners here is my solution:
<Grid>
<Path Stroke="Black" Fill="White" StrokeThickness="10" Stretch="Fill">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<RectangleGeometry Rect="100,200 200,100"/>
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="300,300" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
<Button Margin="10" Height="10" Width="10"/>
</Grid>
You can resize the Rectangle
with changing the values in RectangleGeometry Rect="100,200 200,100
and add inside it any other WPF item.. in this case I added a Button
.
Here's the result:
You could use a Border
in a Border
<Border Background="Black">
<Border Margin="10" Background="White" CornerRadius="20">
<!-- ... -->
</Border>
</Border>
精彩评论