开发者

Inverted Corner Radius in WPF (something like a negative Radius)

开发者 https://www.devze.com 2023-04-10 11:00 出处:网络
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

I try to c开发者_StackOverflowreate a border with a negative Corner radius, like this:

Inverted Corner Radius in WPF (something like a negative Radius)

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 Rectanglewith changing the values in RectangleGeometry Rect="100,200 200,100and add inside it any other WPF item.. in this case I added a Button.

Here's the result:

Inverted Corner Radius in WPF (something like a negative Radius)


You could use a Border in a Border

<Border Background="Black">
    <Border Margin="10" Background="White" CornerRadius="20">
        <!-- ... -->    
    </Border>
</Border>

Inverted Corner Radius in WPF (something like a negative Radius)

0

精彩评论

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