Search code examples
c#wpfxamlrounded-corners

How to draw a half-rounded rectangle?


I want a a half-rounded rectangle like in the image, but rounded only 2 edges.

A Half-Rounded Rectangle

I have tried using RadiusX="" RadiusY="", but that rounded all 4 edges.


Solution

  • If you use a Border you can specify four different radiuses (topLeft, topRight, bottomRight, bottomLeft) separated by a comma, e.g.:

    <Border BorderBrush="Blue" BorderThickness="3" CornerRadius="5,5,0,0" Margin="10">
        <TextBlock>....</TextBlock>
    </Border>